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
Removing media from library does not remove custom image sizes #2
Comments
I was pretty sure that WordPress deletes all the images in the array. I will write some unit tests this week and see why it goes wrong. From there I will start building more functionality like some on-the-fly generation. |
I finally had the time to look into it and now know the issue. WordPress only deletes existing image sizes. I would assume this is a bigger issue then only my class. Going to check things out and see if WordPress needs to be patched. |
The first solution I came up with is when you add an image size, store the name in the options table. Then before you delete an image from media, retrieve the image sizes and add them to the sizes global. If you go this route, I recommend prefixing the $name of the image size when you store it to avoid removing another plugins size on accident. |
Not needed. Long term solution is https://core.trac.wordpress.org/ticket/24518. Also if you didn't check it out yet http://github.com/markoheijnen/improved-image-editor/. Also includes most of the code here. Still need to look if it still can be separated or not. |
Fixed the problem :) |
I'm adding this issue here, because I don't think it directly relates to core in the way my OP did.
http://core.trac.wordpress.org/ticket/25884#comment:3
Your comment references that WP_images removes the custom crops when a user removes the image from the media library. In my tests, they don't.
This is how I've used it.
properly creates the size, so we can call
wp_get_attachment_image();
$meta = $image->get_metadata();
returns the list of crops including the custom crop.When removing the image from the library, the custom crop still exists.
The text was updated successfully, but these errors were encountered: