Skip to content

Commit

Permalink
fix for #926
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Nov 13, 2023
1 parent aaa5523 commit 7d2b543
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const DownloadDialogue = ({
canvases,
confinedImageSize,
content,
downloadCurrentViewEnabled,
downloadWholeImageHighResEnabled,
downloadWholeImageLowResEnabled,
getConfinedImageDimensions,
getConfinedImageUri,
getCroppedImageDimensions,
Expand All @@ -49,6 +52,9 @@ const DownloadDialogue = ({
canvases: Canvas[];
confinedImageSize: number;
content: { [key: string]: string };
downloadCurrentViewEnabled: boolean;
downloadWholeImageHighResEnabled: boolean;
downloadWholeImageLowResEnabled: boolean;
getConfinedImageDimensions: (canvas: Canvas) => Size | null;
getConfinedImageUri: (canvas: Canvas) => string | null;
getCroppedImageDimensions: (canvas: Canvas) => CroppedImageDimensions | null;
Expand Down Expand Up @@ -202,10 +208,18 @@ const DownloadDialogue = ({

switch (option) {
case DownloadOption.CURRENT_VIEW:
if (!downloadCurrentViewEnabled) {
return false;
}

return !paged;
case DownloadOption.CANVAS_RENDERINGS:
case DownloadOption.IMAGE_RENDERINGS:
case DownloadOption.WHOLE_IMAGE_HIGH_RES:
if (!downloadWholeImageHighResEnabled) {
return false;
}

const maxDimensions: Size | null = canvas.getMaxDimensions();

if (maxDimensions) {
Expand All @@ -217,6 +231,10 @@ const DownloadDialogue = ({
}
return true;
case DownloadOption.WHOLE_IMAGE_LOW_RES:
if (!downloadWholeImageLowResEnabled) {
return false;
}

// hide low-res option if hi-res width is smaller than constraint
const size: Size | null = getCanvasComputedDimensions(canvas);
if (!size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,19 +655,24 @@ export default class OpenSeadragonExtension extends BaseExtension {
canvases: canvases,
confinedImageSize: config.options.confinedImageSize,
content: config.content,
downloadCurrentViewEnabled: config.options.downloadCurrentViewEnabled,
downloadWholeImageHighResEnabled:
config.options.downloadWholeImageHighResEnabled,
downloadWholeImageLowResEnabled:
config.options.downloadWholeImageLowResEnabled,
locale: this.getLocale(),
manifest: this.helper.manifest as Manifest,
maxImageWidth: config.options.maxImageWidth,
mediaDownloadEnabled: this.helper.isUIEnabled("mediaDownload"),
open: downloadDialogueOpen,
paged: paged,
parent: this.shell.$overlays[0] as HTMLElement,
resources: this.resources,
requiredStatement: this.helper.getRequiredStatement()?.value,
termsOfUseEnabled: this.data.config.options.termsOfUseEnabled,
resources: this.resources,
rotation: this.getViewerRotation() as number,
selectionEnabled: selectionEnabled,
sequence: this.helper.getCurrentSequence(),
termsOfUseEnabled: this.data.config.options.termsOfUseEnabled,
triggerButton: dialogueTriggerButton as HTMLElement,
getCroppedImageDimensions: (canvas: Canvas) => {
return this.getCroppedImageDimensions(canvas, this.getViewer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
"options": {
"confinedImageSize": 1000,
"currentViewDisabledPercentage": 90,
"downloadCurrentViewEnabled": true,
"downloadWholeImageHighResEnabled": true,
"downloadWholeImageLowResEnabled": true,
"maxImageWidth": 5000,
"optionsExplanatoryTextEnabled": false,
"selectionEnabled": false
Expand Down Expand Up @@ -432,4 +435,4 @@
"skipToDownload": "$skipToDownload",
"termsOfUse": "$termsOfUse"
}
}
}

1 comment on commit 7d2b543

@vercel
Copy link

@vercel vercel bot commented on 7d2b543 Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.