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

Cropped scales are not working with brains (breaks Plone 6) #129

Closed
laulaz opened this issue Apr 4, 2023 · 5 comments
Closed

Cropped scales are not working with brains (breaks Plone 6) #129

laulaz opened this issue Apr 4, 2023 · 5 comments
Labels

Comments

@laulaz
Copy link
Member

laulaz commented Apr 4, 2023

Since plone/Products.CMFPlone#3521, image scales are stored in a catalog metadata.

This is very useful when using RESTAPI, but also to ensure that you have URLs that you can cache easily (if the image changes, the URLs with the hashes change too).

With cropped images, we have a problem : the catalog is not updated at all, and there is a difference between the annotation stored on the content and the image_scales metatada, resulting in NotFound error.

Example on Plone 6 :

  1. add a content with a leadimage
  2. access one of the scale of the leadimage with the unique URL stored in the catalog (ex: http://localhost:8080/Plone/content/@@images/image-390-2aaa08d8385fce6809dfa9fa8dca2a49.jpeg)
  3. crop the scale with the cropping editor
  4. you cannot access the unique URL anymore : you get a 404 error !

We should change p.a.imagecropping to update the image_scales metatada according to cropped scales.
Or do you see any drawback regarding this ? (@cekk maybe ?)
Maybe concerning Volto 😟

@laulaz
Copy link
Member Author

laulaz commented Apr 7, 2023

A bit more about this issue : cropping doesn't work (images are shown as not cropped) everywhere we try to use scales from brains in Plone !

See https://github.com/plone/plone.namedfile/blob/aae60d162e72dbf97e98baca2e9d7d9024532f35/plone/namedfile/scaling.py#L725

Examples :

  • listing views
  • search results
  • recently modified
  • recently published
  • eea.facetednavigation views
  • ...

@laulaz laulaz changed the title Cropped scales not accessible (404) from image_scales metatada URLs Cropped scales are not working with brains Apr 7, 2023
@laulaz laulaz changed the title Cropped scales are not working with brains Cropped scales are not working with brains (breaks Plone 6) Apr 18, 2023
@laulaz laulaz added the bug label Apr 18, 2023
@maethu
Copy link
Member

maethu commented Sep 1, 2023

@laulaz
I ran into similar issues. Basically indexing the new scales might just work. But having delivered a different (cropped) image with the same URL seems to be a bad idea for proxies/cache and browsers. So I implemented #142 It does not solve this issue yet, but it show cases the issue even better. Since now the hash key changes with every cropped image. Which means the catalog is never up-to-date.

I tries to solve it by reindexing the image scales upon crop of an image. But the problem there is, that the new hash key can only be calculated after the transaction was successful. This means the value in the catalog is always too old (from the prev. image).

@petschki
Copy link
Member

could you give the current master branch a try? we've fixed some reindexing and hash calculations here #144

@maethu
Copy link
Member

maethu commented Sep 26, 2023

@petschki Thanks for the work in #144. I implemented the new internal modified timestamp in plone.namedfile exactly for this kind of issues. You were faster than me to implement it here 😅 . Thanks.

It works in my env (plone 6.0.7 + master branch)

@laulaz
Copy link
Member Author

laulaz commented Sep 26, 2023

Thanks for the work @petschki @MrTango !

@laulaz laulaz closed this as completed Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants