question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Images management command to purge and regenerate renditions

See original GitHub issue

Is your proposal related to a problem?

  • Occasionally, you can create problems when syncing data from production environments or you just want to clear out unused renditions.
  • There are also cases where there is a need to clear space on a server and we may want to intentionally only load image renditions when requested.

Describe the solution you’d like

A new management command, in the images app, that provides the ability to regenerate image renditions. With an optional argument to also purge any existing ones.

  • manage.py update_image_renditions - will regenerate all the rendition images (not the DB entries)
  • manage.py update_image_renditions --purge - will first purge all rendition images and then regenerate all the rendition images
  • manage.py update_image_renditions --purge-only - will ONLY purge all rendition images

Describe alternatives you’ve considered

  • Use something like rm -rf within the media folder, however this risks removing images that are not renditions, plus will mean that the next load for users will be slow for each image needed.

Additional context

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lb-commented, Mar 18, 2022

That makes sense and appears to summarise correctly @Hitansh-Shah

As noted above, feel free to start with a simple version of this that simply purges (deletes) renditions (even if that means a different name is needed.

Please also namespace the command. wagtail_update_image_renditions

See https://github.com/wagtail/wagtail/issues/8162 for context

0reactions
Hitansh-Shahcommented, Mar 17, 2022

Hey @lb- , so I looked into the resources and the requirements of this issue. So I am just confirming what I understood so far and what I am planning to do. For regenerating the renditions I will just loop through all the renditions and for each rendition I will use the get_rendition method on rendition.image with rendition.filter as the parameter (all of this in the command function obviously). This will regenerate each and every rendition. I don’t know if I have caught on to the problem, please correct me if I am wrong. If I am in the right direction do let me know so that I can open a draft Pr to work further. Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optimizing drawing files in AutoCAD with Purge, Audit ...
For AutoCAD 2012 and later versions, the PURGE and RECOVER command can be performed simultaneously by using the DWGCONVERT utility.
Read more >
Management commands - Wagtail's documentation
Options: –purge-only : This argument will purge all image renditions without regenerating them. They will be regenerated when next requested.
Read more >
Repair a Windows Image | Microsoft Learn
This command will not unmount images that are already mounted, nor will it delete images that can be recovered using the /Remount-Image command....
Read more >
Image management best practices | Compute Engine ...
To completely delete the image and its data, you must send an explicit delete command for that image. Sharing images between projects. Organizations...
Read more >
Management commands - sorl-thumbnail - Read the Docs
This cleans up the Key Value Store from stale cache. It removes references to images that do not exist and thumbnail references and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found