Skip to content

Commit 0890953

Browse files
committed
Specify sizes where we use the Image component
1 parent 0bb9be7 commit 0890953

File tree

7 files changed

+16
-2
lines changed

7 files changed

+16
-2
lines changed

frontend/packages/volto-light-theme/src/components/Blocks/Listing/GridTemplate.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const GridTemplate = ({ items, linkTitle, linkHref, isEditMode }) => {
4646
className="item-image"
4747
item={item}
4848
imageComponent={PreviewImageComponent}
49+
sizes="auto, (max-width: 940px) 100vw, 940px"
4950
/>
5051
)}
5152
<Card.Summary a11yLabelId={props.a11yLabelId}>

frontend/packages/volto-light-theme/src/components/Blocks/Listing/SummaryTemplate.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const SummaryTemplate = ({ items, linkTitle, linkHref, isEditMode }) => {
4444
item={item}
4545
showPlaceholderImage={true}
4646
imageComponent={PreviewImageComponent}
47+
sizes="auto, (max-width: 768px) 100vw, 220px"
4748
/>
4849
<Card.Summary a11yLabelId={props.a11yLabelId}>
4950
<Summary item={item} HeadingTag="h3" />

frontend/packages/volto-light-theme/src/components/Blocks/Slider/DefaultBody.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ const SliderBody = ({
117117
alt=""
118118
loading="lazy"
119119
responsive={true}
120+
sizes="100vw"
120121
/>
121122
</div>
122123
)}

frontend/packages/volto-light-theme/src/components/Blocks/Slider/SliderVariants.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ const SliderVariants = ({
124124
alt=""
125125
loading="lazy"
126126
responsive={true}
127+
sizes="auto, (max-width: 768px) 100vw, 50vw"
127128
/>
128129
</div>
129130
)}

frontend/packages/volto-light-theme/src/components/Blocks/Teaser/DefaultBody.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const TeaserDefaultTemplate = (props) => {
3131
item={!data.overwrite ? href : { ...href, ...filteredData }}
3232
image={data.overwrite ? image : undefined}
3333
imageComponent={Image}
34+
sizes="auto, (max-width: 940px) 100w, 940px"
3435
/>
3536
<Card.Summary>
3637
<Summary

frontend/packages/volto-light-theme/src/components/Theme/ImageView.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ const ImageView = ({ content }) => {
3030
<h1 className="documentFirstHeading">{content.title}</h1>
3131
{content?.image?.download && (
3232
<figure>
33-
<Image item={content} imageField="image" alt="" responsive={true} />
33+
<Image
34+
item={content}
35+
imageField="image"
36+
alt=""
37+
responsive={true}
38+
sizes="auto, (max-width: 940px) 100vw, 940px"
39+
/>
3440
<Caption
3541
title={content.title}
3642
description={content.description}

frontend/packages/volto-light-theme/src/primitives/Card/Card.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ type CardImageProps = {
9494
imageComponent?: React.ComponentType<any>;
9595
children?: React.ReactNode;
9696
showPlaceholderImage?: boolean;
97+
sizes?: string;
9798
};
9899

99100
const CardImage = (props: CardImageProps) => {
100-
const { src, item, image, imageComponent, showPlaceholderImage } = props;
101+
const { src, item, image, imageComponent, showPlaceholderImage, sizes } =
102+
props;
101103
const Image = imageComponent || DefaultImage;
102104

103105
return (
@@ -115,6 +117,7 @@ const CardImage = (props: CardImageProps) => {
115117
alt=""
116118
loading="lazy"
117119
responsive={true}
120+
sizes={sizes}
118121
/>
119122
)
120123
) : (

0 commit comments

Comments
 (0)