Open krieghan opened 11 months ago
Adding this to wagtail.images.signal_handlers does seem to be sufficient to solve the problem:
def purge_image_renditions_cache(image, **kwargs):
for rendition in image.renditions.all():
renditions.purge_from_cache()
(assuming this line has been added to register_signal_handlers):
post_save.connect(purge_image_renditions_cache, sender=Image)
Just adding this for context for the problem I'm seeing, not necessarily as a proposal. I'm not particularly familiar with this codebase, so if there's some other mechanism for managing the cache that should be triggered on these updates, that's something I'm curious about.
Does updating the image renditions make any difference?
./manage.py wagtail_update_image_renditions
@lb- it should, however that is quite the nuclear option and we should clear just the renditions for the image one changes the focal point for
Yep. That's fair.
Note on the preview page that the image's focal point still shows the old value
@krieghan Can you clarify what you mean by the preview page?
I have attempted reproducing the error. This is what I have tried:
Here is the old focal point:
Here is the new focal point:
You can provide more information if I am missing something in reproducing the error. Thanks.
I'm specifically talking about the "preview" option in the page edit admin:
When I update the image focal point, the page preview displays with the old focal point. I don't know if anyone else has reproduced this issue, but it seems like a general bug.
@krieghan Oh, I see. Let me check that
@krieghan Can I understand you better? Do you mean the focal point (the green box) would appear on the image on the preview? Look at what I have here. The full image appears on preview regardless of a defined focal point area
For starters, I've been viewing the preview in a separate page (the far right link on that toolbar). The other thing is that the focal point is only relevant if the full image is larger than the image area on the page.
Oh, okay. Thanks.
Issue Summary
When updating an image focal point in the edit interface, edits aren't reflected on the page. This seems to be due to caching. The Rendition object is cached, along with the focal point cached_property. This cache doesn't seem to be invalidated on save, nor is the object in the cache updated. This means that the value of the focal point in the database is correct, but the focal point from the cache is not. Consequently, as stated, the page will continue to show the old focal point until the cache is manually invalidated
Steps to Reproduce
Technical details