Limit image scales to those smaller than the original#1992
Limit image scales to those smaller than the original#1992
Conversation
|
@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: 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! |
|
@jenkins-plone-org please run jobs |
jensens
left a comment
There was a problem hiding this comment.
You need an exception for SVG images.
|
@jensens Why an exception for SVG images? |
mauritsvanrees
left a comment
There was a problem hiding this comment.
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"
a) SVG naturally scales up - its vector. |
|
Correct, it's vector graphics and does not need scales at all |
Misconception, if you dont apply a size to display it the SVG will show somehow (if not constrained by CSS, what you never know). So setting the size for display as we do already is good, but sufficient, we dont need to change anything, just keep as is. |
|
I disagree that we should not assume we have a theme on our sites, which is what I understand from your comment. If the theme does not constrain images properly, I don't think it's an issue at the lower level. That being said, I did not mean that a proper svg image should not have it's own set of dimensions, I'm saying you don't need to generate more scales just to set different dimensions on it, imho. I would rather not have this kind of code to maintain if it was mine. |
|
The code its simple enough and no burden. |
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/