Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templates should use @@images.tag #3535

Open
mauritsvanrees opened this issue May 19, 2022 · 2 comments
Open

Templates should use @@images.tag #3535

mauritsvanrees opened this issue May 19, 2022 · 2 comments
Assignees
Milestone

Comments

@mauritsvanrees
Copy link
Member

Several templates use code like this:

<img tal:define="scale context/@@images"
    tal:replace="structure python:scale.scale('image', scale='large').tag(css_class='figure-img img-fluid')" />

Instead of first calling the scale function and calling tag on the result, we should call the tag method directly:

<img tal:define="scale context/@@images"
    tal:replace="structure python:tag('image', scale='large', css_class='figure-img img-fluid')" />

The old way will not benefit from the plone.scale and plone.namedfile improvements for making a split between creating a tag and creating the actual scale.

A quick search shows templates in plone.app.contenttypes and plone.app.event that can be improved, but there may be more, as it is hard to search for this specific problem.

@mauritsvanrees mauritsvanrees self-assigned this May 19, 2022
mauritsvanrees added a commit to plone/plone.app.contenttypes that referenced this issue May 19, 2022
mister-roboto pushed a commit to plone/buildout.coredev that referenced this issue May 20, 2022
Branch: refs/heads/master
Date: 2022-05-19T17:26:18+02:00
Author: Maurits van Rees (mauritsvanrees) <[email protected]>
Commit: plone/plone.app.contenttypes@f347ab2

When using images view, call tag directly.

See plone/Products.CMFPlone#3535

Files changed:
A news/3535.bugfix
M plone/app/contenttypes/behaviors/leadimage.pt
M plone/app/contenttypes/browser/templates/image.pt
M plone/app/contenttypes/browser/templates/listing_summary.pt
M plone/app/contenttypes/tests/test_image.py
Repository: plone.app.contenttypes

Branch: refs/heads/master
Date: 2022-05-20T10:09:57+02:00
Author: Maurits van Rees (mauritsvanrees) <[email protected]>
Commit: plone/plone.app.contenttypes@85f93a7

Fixed album view when a folder has no image.

Files changed:
M plone/app/contenttypes/browser/templates/listing_album.pt
Repository: plone.app.contenttypes

Branch: refs/heads/master
Date: 2022-05-20T15:44:14+02:00
Author: Jens W. Klein (jensens) <[email protected]>
Commit: plone/plone.app.contenttypes@efa69bf

Merge pull request #647 from plone/maurits-images

When using images view, call tag directly.

Files changed:
A news/3535.bugfix
M plone/app/contenttypes/behaviors/leadimage.pt
M plone/app/contenttypes/browser/templates/image.pt
M plone/app/contenttypes/browser/templates/listing_album.pt
M plone/app/contenttypes/browser/templates/listing_summary.pt
M plone/app/contenttypes/tests/test_image.py
@jensens
Copy link
Member

jensens commented Mar 12, 2023

Is this solved with the above PR?

@mauritsvanrees
Copy link
Member Author

No, in my original comment I noted a problem in plone.app.event and that is not solved yet. And there are likely more templates that need fixing. It is a bit hard to get a full list of problems without also getting false positives. We may need to go through all templates that use @@images and check each use.

@jensens jensens added this to the Plone 6.1 milestone Mar 13, 2023
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

No branches or pull requests

2 participants