I am using feeds importer for importing images. I have mapped the column "Image" in my CSV to the "Image: URI (field_image:uri)" field in my importer configuration. It workds for now when I put only one image URL in the CSV file, but how to import multiple images?
1 Answer
You can accomplish this with choosing a character to separate your image urls with in the CSV file and using the Feeds Tamper plugin "Explode".
Separate the image URLs in your CSV file with a certain character, for example a pipe character: "|". Your CSV file could then look something like this:
title,image Lorem Ipsum,http://www.example.com/image1.png|http://www.example.com/image2.png
Install the module Feeds Tamper. Also enable the Feeds Tamper Admin UI module (included with Feeds Tamper).
- Go the Tamper page of your feeds importer (/admin/structure/feeds/[importer_id]/tamper).
- Click "Add plugin" for the "Image: URI" mapper.
- For the plugin to add, select "Explode". As string separator, choose the character that you used to separate your image URLs. If you followed the example, then this would be the pipe character: "|". See also the image:
The explode tamper plugin cares that your input data (for example "http://www.example.com/image1.png|http://www.example.com/image2.png") is handled as multiple values.
-
This works like a charm. Just an appreciation, if you have a "add prefix" like in my case, just remember that the order of plugins matters. First apply the "explode" plugin and after the "add prefix". Kyke– KykeCommented May 11, 2018 at 17:43
-
@megachriz How to do it when I already have images downloaded?– UmairCommented Jun 20, 2018 at 20:17
-
@Umair You could import the images again. Per entity, Feeds will empty the field first before putting a value on it. So you won't get duplicate values on fields. Commented Jun 21, 2018 at 18:44
-
@MegaChriz I did not explain clearly. I mean if I have images on my computer.– UmairCommented Jun 23, 2018 at 0:11
-
For me it doesn't work with D8. drupal.org/project/feeds_tamper/issues/3103193– VasyOKCommented Dec 26, 2019 at 20:49