syamilmj / Aqua-Resizer

Resize WordPress images on the fly
502 stars 208 forks source link

Deleting Aqua Resized Imgs (request) #19

Open wpexplorer opened 11 years ago

wpexplorer commented 11 years ago

Would it be possible to apply a custom meta ID to images added using aqua resizer and then have a function that can loop through these and delete them? This way if someone stops using a theme that uses aqua resizer they could easily delete all images created by the script?

Or even be able to have a button in the theme panel that deletes them.

Would love to see some sort of system like this and of course would donate for the update ;)

Firestorm-Graphics commented 11 years ago

arent the images resized on the fly ???? so only the origional images uploaded will get resized on page load therefore theres no stored images to delete, am i wrong ???

guilima commented 7 years ago

When the original image is deleted the aqua resized one aren't. So if you upload an image that has the same name as the deleted one, it isn't generated again. Is this problem persisting in the last version (1.2.1) ? Because maybe I need to update it.

wpexplorer commented 7 years ago

@guilima I actually use a whole new function in my themes now I created from scratch that actually uses attachment ID's to process the image instead of a url which means you can update the attachment meta to include the cropped image as a new size hence fixing issues with CDN's and image deletions, maybe something to consider doing for your own site, it's a fairly easy tweak if you are modifying the aq class.

See the following core functions:

So instead of parsing an image URL send an attachment ID to the class and use the functions listed above to get the image path, crop things and once cropped use wp_update_attachment_metadata() to update the image metadata to add your custom size to the list if sizes in the array, then return your new image via wp_get_attachment_image_src().

koraysels commented 6 years ago

@wpexplorer Any chance you can create a Pull Request out of your modified code? or a fork? I think it would benfit lots of users of Aqua resizer...

EDIT: or is it this one ? https://github.com/wpexplorer/nova-wp-image-resizer

wpexplorer commented 6 years ago

@koraysels - Yes, this is the new script I will start to use: https://github.com/wpexplorer/nova-wp-image-resizer - but it's coded from scratch it's not based on Aqua resizer. Give it a try and see if you like it. And you can easily integrate it with wp_get_attachment_image_src to provide auto resizing for thumbnails defined via add_image_size - which is what I'm doing in my upcoming themes.