Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rmens opened this issue Apr 12, 2020 · 5 comments
Open

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

rmens opened this issue Apr 12, 2020 · 5 comments

Comments

@rmens
Copy link

rmens commented Apr 12, 2020

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?

@awps
Copy link
Contributor

awps commented Apr 15, 2020

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.

@rmens
Copy link
Author

rmens commented Apr 26, 2020

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)

@adityathok
Copy link

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

707cb1a

@bsgdigital
Copy link

I've made a PR for this quite some time ago #112 - it updates attachment metadata with the new sizes, so WP is aware of them and deletes when needed

@rmens
Copy link
Author

rmens commented Aug 9, 2023

Can that PR be merged please @syamilmj?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants