I’ve passed a direct URL to an image on my site into the wp_get_image_editor() function, and the function always returns the “invalid_image” error.
The URL is certainly correct and the image is certainly real; Chrome lets me click the URL in the debug output and it opens a new tab showing the image. The image is a 620Ã413 JPEG, so it’s not exactly an edge case (I also tested a 700Ã490 png just to be sure). I also tried using the URL of an unrelated publicly-accessible image that I found on Google image search, and the same thing happened.
To make things extra confusing, this is happening inside of a plugin that worked perfectly on the Ubuntu install I developed it on, and started throwing a fit only after I deployed it to a production server. This makes me wonder if it might be some sort of esoteric configuration issue, but I don’t see how it could be. I’m using WordPress 4.2.2.
Finally solved this by using the local path to the image instead of the public path (
wp-content/uploads/2015/06/my_image.png
instead ofwww.mysite.com/wp-content/uploads/2015/06/my_image.png
). WordPress could really use more helpful messaging here.Additionally, here is a function to use everywhere in the website. Add this in functions.php:
Call this as: