Example:
["images"]=>
array(6) {
[0]=>
array(2) {
["src"]=>
string(112) "https://nz.tradevine.com/BlobStorage/GetFullPhoto?photoID=3783754511503592459&organisationID=3468490059683634443"
["position"]=>
string(1) "0"
}
The image is https://nz.tradevine.com/BlobStorage/GetFullPhoto?photoID=3783754511503592459&organisationID=3468490059683634443
I get an error: "Error: Invalid image: Sorry, you are not allowed to upload this file type. [woocommerce_api_product_image_upload_error]
I change WP_config file to allow any type of file upload.
define(‘ALLOW_UNFILTERED_UPLOADS’, true);
it trys to upload a file called: GetFullPhoto
no .jpg
and it does not work.
This ust to work fine.
Any ideas?
2
Answers
WordPress determines the image type from filename and the image doesn’t have an extension, so you will need to get the image extension using
mime_content_type
, update the image filename with that extension for saving and set the image mime-type and image extension array at filetype check hookBecause the url doesn’t include a file extension in it’s name, WordPress treats it as a file with no extension thus failing the
wp_check_filetype_and_ext
test.You can add a filter to add
.jpg
to the end of a filename if it has no extension and is in fact a jpeg like soEDIT:
A more complete solution to work for all image types