Skip to content

Limit image scales to those smaller than the original#1992

Open
davisagli wants to merge 2 commits intomainfrom
image-scales-not-larger-than-original
Open

Limit image scales to those smaller than the original#1992
davisagli wants to merge 2 commits intomainfrom
image-scales-not-larger-than-original

Conversation

@davisagli
Copy link
Member

@davisagli davisagli commented Feb 27, 2026

This makes the serialization of scales for image fields more consistent with the set of scales that comes from image_scales in catalog results. And it avoids storing duplicate data for large scales.

Related to plone/volto#7655


📚 Documentation preview 📚: https://plonerestapi--1992.org.readthedocs.build/

@davisagli davisagli requested a review from sneridagh February 27, 2026 01:29
@mister-roboto
Copy link

@davisagli thanks for creating this Pull Request and helping to improve Plone!

TL;DR: Finish pushing changes, pass all other checks, then paste a comment:

@jenkins-plone-org please run jobs

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically.

Happy hacking!

@davisagli
Copy link
Member Author

@jenkins-plone-org please run jobs

@davisagli davisagli requested a review from pnicolli February 27, 2026 01:33
Copy link
Member

@sneridagh sneridagh left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@jensens jensens left a comment

Choose a reason for hiding this comment

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

You need an exception for SVG images.

@davisagli
Copy link
Member Author

@jensens Why an exception for SVG images?

@pnicolli pnicolli moved this from Todo to In progress in Bucharest Sprint 2026 Mar 10, 2026
Copy link
Member

@mauritsvanrees mauritsvanrees left a comment

Choose a reason for hiding this comment

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

Makes sense.

I suppose for SVG a larger scale does not bloat the database, as we scale this by editing the XML contents. Use here in plone.namedfile after checking the content type. So this could work:

if actual_width > width and getattr(field, "contentType", "") != "image/svg+xml"

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

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

5 participants