diff --git a/__tests__/CanvasDownloadLinks.test.js b/__tests__/CanvasDownloadLinks.test.js index 8a14e5d..6419e6c 100644 --- a/__tests__/CanvasDownloadLinks.test.js +++ b/__tests__/CanvasDownloadLinks.test.js @@ -12,6 +12,7 @@ function createWrapper(props) { canvasId="abc123" canvasLabel="My Canvas Label" classes={{}} + fullSizeParam="max_full" infoResponse={{}} restrictDownloadOnSizeDefinition={false} viewType="single" @@ -179,7 +180,7 @@ describe('CanvasDownloadLinks', () => { const link = screen.getByRole('link', { name: /Whole image \(4000 x 1000px\)/i }); expect(link).toBeInTheDocument(); - expect(link).toHaveAttribute('href', 'http://example.com/iiif/abc123/full/full/0/default.jpg?download=true'); + expect(link).toHaveAttribute('href', 'http://example.com/iiif/abc123/full/max_full/0/default.jpg?download=true'); }); describe('For Images Wider Than 1000px', () => { @@ -187,7 +188,7 @@ describe('CanvasDownloadLinks', () => { createWrapper({ canvas }); const link1 = screen.getByRole('link', { name: /Whole image \(4000 x 1000px\)/i }); - expect(link1).toHaveAttribute('href', 'http://example.com/iiif/abc123/full/full/0/default.jpg?download=true'); + expect(link1).toHaveAttribute('href', 'http://example.com/iiif/abc123/full/max_full/0/default.jpg?download=true'); const link2 = screen.getByRole('link', { name: /Whole image \(1000 x 250px\)/i }); expect(link2).toHaveAttribute('href', 'http://example.com/iiif/abc123/full/1000,/0/default.jpg?download=true'); diff --git a/src/CanvasDownloadLinks.js b/src/CanvasDownloadLinks.js index 839bf87..febe220 100644 --- a/src/CanvasDownloadLinks.js +++ b/src/CanvasDownloadLinks.js @@ -34,13 +34,13 @@ export default class CanvasDownloadLinks extends Component { } zoomedImageUrl() { - const { canvas } = this.props; + const { canvas, fullSizeParam } = this.props; const bounds = this.currentBounds(); const boundsUrl = canvas .getCanonicalImageUri() .replace( /\/full\/.*\/0\//, - `/${bounds.x},${bounds.y},${bounds.width},${bounds.height}/full/0/`, + `/${bounds.x},${bounds.y},${bounds.width},${bounds.height}/${fullSizeParam}/0/`, ); return `${boundsUrl}?download=true`; @@ -53,11 +53,11 @@ export default class CanvasDownloadLinks extends Component { } fullImageUrl() { - const { canvas } = this.props; + const { canvas, fullSizeParam } = this.props; return `${canvas .getCanonicalImageUri() - .replace(/\/full\/.*\/0\//, '/full/full/0/')}?download=true`; + .replace(/\/full\/.*\/0\//, `/full/${fullSizeParam}/0/`)}?download=true`; } thousandPixelWideImage() { @@ -223,6 +223,7 @@ CanvasDownloadLinks.propTypes = { getWidth: PropTypes.func.isRequired, }).isRequired, canvasLabel: PropTypes.string.isRequired, // canvasLabel is passed because we need access to redux + fullSizeParam: PropTypes.string.isRequired, infoResponse: PropTypes.shape({ json: PropTypes.shape({ height: PropTypes.number, diff --git a/src/MiradorDownloadDialog.js b/src/MiradorDownloadDialog.js index c102790..423edca 100644 --- a/src/MiradorDownloadDialog.js +++ b/src/MiradorDownloadDialog.js @@ -87,19 +87,33 @@ export class MiradorDownloadDialog extends Component { Download - {canvases.map((canvas) => ( - - ))} + {canvases.map((canvas) => { + const imageInfo = infoResponse(canvas.id); + const context = imageInfo.json && imageInfo.json['@context']; + let contextArray; + if (Array.isArray(context)) { + contextArray = context; + } else if (typeof context === 'string') { + contextArray = [context]; + } + const fullSizeParam = contextArray && contextArray.indexOf('http://iiif.io/api/image/3/context.json') > -1 + ? 'max' : 'full'; + + return ( + + ); + })} {this.renderings().length > 0 && (