2

For the past couple year we've uploaded our configurable product images to the parent product. We're implementing some new procedures that require specific images to be uploaded to each child product as well.

I'm using a bulk import to associate these images with their respective child products. All images have been placed in the /media/import folder, and the import sheet has been configured with the images listed under the "image" column, formatted as /image-filename.jpg

Upon attempting to upload the file and import the images, Magento gives me an error for each entry claiming "Invalid image file type." The research I've done so far only elaborates as far as saying that Magento only accepts 'jpg', 'jpeg', 'gif', and 'png' image types, but of course all my images are '.jpg'

Any ideas why Magento wouldn't like my .jpg's?

0

You can put a var_dump in app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php around line 280 and see what do you have inside $pathinfo. Code is quite clear, it seems to check the extension of the file you are uploading only.

    $pathinfo = pathinfo($file);
    $imgExtensions = array('jpg','jpeg','gif','png');
    if (!isset($pathinfo['extension']) || !in_array(strtolower($pathinfo['extension']), $imgExtensions)) {
        Mage::throwException(Mage::helper('catalog')->__('Invalid image file type.'));
    }
  • Pardon my ignorance, but my experience with PHP is not extensive. I've added in var_dump($pathinfo); immediately after that line. How does one then retrieve the result? I imagine it would be a matter of running the import again, and checking either the page source, or the system.log, but I'm not seeing it. – blockletter Jul 10 '15 at 16:37
  • 1
    If you run the import again you should see a blank page with some vars in it. – mbalparda Jul 10 '15 at 16:40
0

This issue was easily resolved by modifying my CSV file. The "Invalid image file type" error was being caused by the "small_image" field, not the "image" field. When I initially began working on my spreadsheet, I prepopulated both of those columns with a "/" so that I wouldn't miss any. While the importer may have successfully been importing the files listed under image, it was not happy about the slashes left behind in the small_image field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.