Importing images with special characters in path
-
15-04-2021 - |
Frage
I am trying to import a lot of images. Images for each product are placed in subfolders by product IDs and locale.
The problem is that each locale specific folder name starts with a caret (^
).
Example image paths:
9454032/^all/my_image.jpg
9454032/^en/my_english_image.jpg
What I'm getting
1. Wrong URL/path used for attribute image in row(s): 1, 2
2. Wrong URL/path used for attribute small_image in row(s): 1, 2
3. Wrong URL/path used for attribute thumbnail in row(s): 1, 2
4. Wrong URL/path used for attribute additional_images in row(s): 1, 2
What I've tried
- Encoding
^
to%5E
, like in URLs - Simply removing the caret from
What I'm sure of
- CSV file encoding; I'm using Sublime text, besides Mac's Numbers, to verify the data
- Image path is correct, because it works without the caret in the path
- Multiple images (in
additional_images
) are separated correctly, with|
, and specified in the importer - There are no other special characters in the image names
- No extra slash in the beginning of the image path
Possible solutions
- A shell script to rename all folders containing
^
, although I'd like to avoid altering original data for consistency reasons
References
Versions
- Magento 2.3.5-p1
- PHP 7.3.24
Lösung
There's no way around it. You have to sanitize the images URLs. I've written a python script to remove non-alphanumeric characters from the full path of each image.
Also, this version of Magento limits the image name to 90 characters by default. Some posts show a workaround for that.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange