collective / plone.app.imagecropping

Crops Images in Plone manually using cropper JS library
https://pypi.python.org/pypi/plone.app.imagecropping
9 stars 23 forks source link

Make sure the hash key changes after cropping an image. #142

Closed maethu closed 1 year ago

maethu commented 1 year ago

Problem:

Even though an image gets changed via cropping it does maintain the same url. Which leads cache/proxy and browsers to potentially not download the new version of the cropped image.

Example: After uploading a new image the url to the thumb scale is http://nohost/plone/testimage/@@images/image-128-fba13e5e2040bf30b80360aeaf2bb42f.png

After cropping the url is still http://nohost/plone/testimage/@@images/image-128-fba13e5e2040bf30b80360aeaf2bb42f.png

Explenation: One part of the hash key in the default storage (IImageScaleStorage) is the _p_mtime (modification time if an object got changed during a transaction). This is basically the only parameter that we can change, without rewriting the storage, image factory and utilities.

Solution: Mark the ImageBlobField as changed if a scale gets cropped. This way we force the storage to generate a new has key for (all) the scales.

maethu commented 1 year ago

@petschki I'm sorry can't really tell what's wrong with the tests. I might need help to fix those.

petschki commented 1 year ago

Somehow the test is broken after merging it into master. @maethu could you eventually take a look again?

MrTango commented 1 year ago

strange, the strings look exactly the same

MrTango commented 1 year ago

strange, the strings look exactly the same

which is the problem, they shouldn't :)