wp_get_image_editor uncaught error when file is not an image
-
I am doing some testing on an image upload script via AJAX I am working on and part of that script is to edit the image (size) with wp_get_image_editor.
I wanted to test to see what would happen if somehow somebody uploaded a file that is not an image file. When it gets to the point where trying to initiate the editor (with a .txt file), the result from the AJAX call is always 500. It seems that if a non image file is sent to the wp_get_image_editor function, it craps out with an uncaught error.
I think what would be good idea is to return an WP_Error if the file is not an image.
I know wp_get_image_editor calls wp_check_filetype, so for a test I ran the uploaded file through the wp_check_filetype on its own, and it returned a MIME type plain/text for the .txt file.
Is there some way to get wp_get_image_editor to return an error if a non image file is sent as the path argument?
Cheers
- The topic ‘wp_get_image_editor uncaught error when file is not an image’ is closed to new replies.