Aqua-Resizer icon indicating copy to clipboard operation
Aqua-Resizer copied to clipboard

Resized images not deleted on deleting original image in wp-admin

Open rmens opened this issue 4 years ago • 5 comments

When an image is deleted via the wp-admin media library, all the sizes generated by WordPress are deleted, but not the sizes generated by the Aqua-Resizer. This leaves a whole lot of junk on the filesystem.

Is it possible to make a function that hooks into wp_delete_attachment to let Aqua-Resizer cleanup after itself?

rmens avatar Apr 12 '20 10:04 rmens

This library generates images on the fly and does not save its data in DB. So deleting the files from the uploads folder may be risky if not done correctly.

awps avatar Apr 15 '20 10:04 awps

I see. There is limited data to work with, but I'm thinking of:

  • Filename
  • Hash of file
  • Extension
  • Folder (month, year if this setting is enabled in WordPress)

rmens avatar Apr 26 '20 11:04 rmens

I tried it with this, and it worked. but only for file names that have been saved

https://github.com/syamilmj/Aqua-Resizer/pull/118/commits/707cb1a8e7bdb7c10072577b69bba6db482a276b

adityathok avatar Sep 25 '20 03:09 adityathok

I've made a PR for this quite some time ago https://github.com/syamilmj/Aqua-Resizer/pull/112 - it updates attachment metadata with the new sizes, so WP is aware of them and deletes when needed

bsgdigital avatar Nov 13 '20 15:11 bsgdigital

Can that PR be merged please @syamilmj?

rmens avatar Aug 09 '23 08:08 rmens