Closed zzramesses closed 3 years ago
Hi @zzramesses thanks for this issue. Just confirm: Do you get an error when you try to delete an image from the WP back-end as well? Or just from your custom script?
Deleting from the admin area works just fine.
Just checking back in on this
Hey @zzramesses it looks like the code triggers before WP_Filesystem()
has had the chance to initialize. Does your code execute on some hook? I'd suggest triggering your code after plugins_loaded
Hi closing this out for now, feel free to reply here!
Hi @junaidbhura,
I've got a bunch of custom API routes that integrate with another system, one of these routes is a DELETE
route for images. The routes are setup using the rest_api_init
hook. When I try and delete images through this route I get the same error as the original poster.
As per the original post, I'm using the wp_delete_attachment()
method.
Any help would be greatly appreciated.
Hey @joelgraham and @zzramesses I've added a fix for this in 2.0.8
. Can you update the plugin and see if this resolves your issue?
One thing to note though: You might have to delete the dynamic Fly images for those deleted images yourself in this case.
Hello. I have written code that periodically gets a set of posts and updates their post thumbnail from an image url that is saved as post meta. Before it saves the new post thumbnail it deletes the current thumbnail using wp_delete_attachment(). I'm pasting the url to a gist that has both my code and the error log. The plugin is creating a fatal error when I try to delete the image. https://gist.github.com/zzramesses/2e84e26c042c57df04eba86c617ca07c