Importing Images with Regional Symbols in the File Names in Prestashop

September 30, 2014 Alex Simonchik Prestashop, Tips&Tricks
Importing Images with Regional Symbols in the File Names in Prestashop

Here is a small tip how to import images that use regional symbols in the file names, for example such as “Rødvin”.

The thing is that the default import is not able to upload pictures that have such characters in the name, that is why as a result you will see just a picture with a grey question mark instead of the product image. The problem is that AdminImportController::productImport() uses the URL of the image just as it is:

However, if you replace that line with this one:

This will fix the problem. I.e, you need to replace the variable ‘$url’ with ‘dirname($url) . ‘/’ .urlencode(basename($url)’.



2 comments

  1. 1. If you look at the productImport() method you see that variable $url is «partially encoded» with $url = str_replace(‘ ‘, ‘%20’, $url); So if there was space in the original file name your encoding will corrupt it.

    2. You encode only the last part of the URL. But there can be more places to encode. Ex.: http://example.com/some strange symbol folder/image name with some strange symbols.jpg

    3. Method call is not the correct place where to make such modifications.
    Update AdminImportController::copyImg() method. Change

    to the

    UPD: this patch was added to the Prestashop repo

Post a new comment

top