0

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 1

4

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".

  1. 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

  2. Install the module Feeds Tamper. Also enable the Feeds Tamper Admin UI module (included with Feeds Tamper).

  3. Go the Tamper page of your feeds importer (/admin/structure/feeds/[importer_id]/tamper).
  4. Click "Add plugin" for the "Image: URI" mapper.
  5. 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: Feeds Tamper "Explode" plugin

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.

5
  • 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
    – Kyke
    Commented May 11, 2018 at 17:43
  • @megachriz How to do it when I already have images downloaded?
    – Umair
    Commented 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.
    – MegaChriz
    Commented Jun 21, 2018 at 18:44
  • @MegaChriz I did not explain clearly. I mean if I have images on my computer.
    – Umair
    Commented Jun 23, 2018 at 0:11
  • For me it doesn't work with D8. drupal.org/project/feeds_tamper/issues/3103193
    – VasyOK
    Commented Dec 26, 2019 at 20:49

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