wagtail / wagtail

A Django content management system focused on flexibility and user experience

Home Page:https://wagtail.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wagtail_update_image_renditions appears to sometimes clobber its own renditions

jakeisonline opened this issue · comments

Issue Summary

When running ./manage.py wagtail_update_image_renditions with a populated /media/original_images directory, but an empty /media/images directory, the command outputs a success message to terminal, but /media/images remains empty, or is sometimes populated with a handful of image files, but not the amount I would expect.

Observing the /media/images directory while the command is running shows two possible behaviours:

  1. A rendition file is added, but then suddenly deleted, ultimately resulting in an empty /media/images directory
  2. A rendition file is added, and remains, while further rendition files are also added, but then suddenly deleted

In either case, the command reports success.

Added context

We had intended on utilising wagtail_update_image_renditions to ease the seeding of data for new developers onboarding into our project, or for folks needing to completely reset. We seed the database with an export of dummy/placeholder content, which includes images with renditions.

Our intent was to only commit /original_images and then use wagtail_update_image_renditions to create the renditions. We could commit the renditions to (/images), but that could mean committing a very large number of images over time.

I appreciate this issue might be due to how I'm utilising the command, and would be happy to be told as much :)

Steps to Reproduce

  1. Export a site, with one of more images that utilise renditions in templates
    • We use the following command to export: python manage.py dumpdata core wagtailcore wagtailimages --natural-foreign --indent 4 -e contenttypes -e djangae -e wagtailcore.groupcollectionpermission -e wagtailcore.grouppagepermission --e auth.permission -e sessions \> export.json
  2. Reset your database, run all migrations
  3. Import the previously exported data
    • We use the following command for importing: python manage.py loaddata path/to/export.json
  4. Delete your /media/images directory
  5. Run python ./manage.py wagtail_update_image_renditions

Expected outcome: ./media/images is populated with image renditions, and upon spinning up the server there are no broken images.

Actual outcome: ./media/images is either empty or does not have the right number of files, and upon spinning up the server there are broken images.

Any other relevant information

  • Wagtail has been integrated into our existing Django project, using this doc as a guide
  • Running the above steps using --purge-only results in a good outcome, with the image renditions being created upon page request

Technical details

  • Operating System: MacOS 12.7.2
  • Python version: 3.8.16
  • Django version: 3.2
  • Wagtail version: 5.2.2
  • Browser version: Not relevant