Skip to content

Only include the original image in the Image component if the image does not have all the scales present. Fixed and update tests.#7655

Open
sneridagh wants to merge 9 commits intomainfrom
donotaddoriginalimagetothesrcset
Open

Only include the original image in the Image component if the image does not have all the scales present. Fixed and update tests.#7655
sneridagh wants to merge 9 commits intomainfrom
donotaddoriginalimagetothesrcset

Conversation

@sneridagh
Copy link
Member

@sneridagh sneridagh commented Nov 24, 2025

Follow up: #7486 (Seven PR):

  • Add a default scale size which is large enough to serve full-width images on a large high-DPI monitor -> Add 2k and 4k scale sizes plone.volto#205
  • Fix the image field serializer in plone.restapi to include the same scales as the code which creates image_scales for the catalog (so that we aren't generating scales larger than the original).
  • Always set sizes appropriately when we use the Image component (so that we don't end up with the largest scale when a smaller one would be sufficient)

@sneridagh sneridagh requested a review from davisagli November 24, 2025 12:37
Copy link
Member

@davisagli davisagli left a comment

Choose a reason for hiding this comment

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

The presence of the original image didn't force the browser to choose it. But we set width and height to the original size and in most cases didn't set sizes, so the browser didn't have any way to know it could use a smaller scale.

I think setting sizes appropriately would allow the browser's scale selection to work better even if we did always include the original image. I have a slight preference for leaving the original image there, because if we remove it then it takes extra work to use it in the use cases where it's really what you need (i.e. full-width on a large monitor)

alt=""
loading="lazy"
responsive={true}
sizes="(max-width: 940px) 100vw, 940px"
Copy link
Member

Choose a reason for hiding this comment

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

Ideally we should use a smaller size when there are multiple columns.

I don't love hardcoding the default width, but I don't have a better suggestion. We can't use CSS properties because the whole point of sizes is to give the browser enough information to pick the right image before CSS has loaded.

Co-authored-by: Steve Piercy <web@stevepiercy.com>
@sneridagh
Copy link
Member Author

@stevepiercy I accepted all the suggestions, but David is working in the backend side, and we might amend them a bit the next days. Thanks!

@stevepiercy
Copy link
Collaborator

@sneridagh @davisagli please ping me again for a review when it's done cooking.

@stevepiercy
Copy link
Collaborator

Can someone else fix the broken links? I'm swamped.

https://github.com/plone/volto/actions/runs/19663404467/job/56314471303?pr=7655

@sneridagh
Copy link
Member Author

@stevepiercy it seems medium added some antibot measures... we cannot do anything about it. How do we proceed with this use cases?

@stevepiercy
Copy link
Collaborator

@sneridagh for Medium, ignore the entire domain with a regex in conf.py. There are existing examples. It also needs to be applied to the upstream plone/documentation conf.py.

For the others, fix the links that redirect.

@sneridagh
Copy link
Member Author

@davisagli once plone/plone.volto#205 is merged and released, we can go for this one. We might want to amend the docs with the released p.volto version.

@stevepiercy I amended the docs to reflect the latest changes.

alt=""
loading="lazy"
responsive={true}
sizes="auto, (max-width: 940px) 100vw, 940px"
Copy link
Member

Choose a reason for hiding this comment

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

It would be better if this were a configuration. Different themes may have different sizes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants