Skip to content

Commit

Permalink
create thumbnail from image service if there is no thumbnail service
Browse files Browse the repository at this point in the history
  • Loading branch information
gestchild committed Nov 1, 2024
1 parent c1fa7e2 commit 4d4f47d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion content/webapp/components/IIIFViewer/IIIFCanvasThumbnail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { FunctionComponent, useState } from 'react';
import styled from 'styled-components';

import { font } from '@weco/common/utils/classnames';
import { iiifImageTemplate } from '@weco/common/utils/convert-image-uri';
import LL from '@weco/common/views/components/styled/LL';
import Space from '@weco/common/views/components/styled/Space';
import { useUser } from '@weco/common/views/components/UserProvider/UserProvider';
Expand Down Expand Up @@ -78,6 +79,9 @@ const IIIFCanvasThumbnail: FunctionComponent<IIIFCanvasThumbnailProps> = ({
const { user } = useUser();
const role = user?.role;
const isRestricted = canvas.hasRestrictedImage;
const urlTemplate = canvas.imageServiceId
? iiifImageTemplate(canvas.imageServiceId)
: undefined;

return (
<IIIFViewerThumb>
Expand All @@ -97,7 +101,10 @@ const IIIFCanvasThumbnail: FunctionComponent<IIIFCanvasThumbnailProps> = ({
<IIIFViewerImage
highlightImage={highlightImage}
width={canvas?.thumbnailImage?.width || 30}
src={canvas?.thumbnailImage?.url}
src={
canvas?.thumbnailImage?.url ||
(urlTemplate && urlTemplate({ size: '200,' }))
}
srcSet=""
sizes={`${canvas?.thumbnailImage?.width || 30}px`}
alt=""
Expand Down

0 comments on commit 4d4f47d

Please sign in to comment.