6

I have a large catalog import where the items often refer to a single common image (such as "brand_logo"). When I import the images via CSV parser, if the item refers to the same image file, an incremented duplicate is created.

Example: Using the example files supplied with the module, I modified 2 books to use the same image file, which are imported to files/field/image/ as 51JQbhO0MmL.jpg and 51JQbhO0MmL_0.jpg.

This causes the images directory to balloon to 20 times the size it should be (lots of shared images).

Honestly, what I would prefer to do is to upload the images to the site separately (manually, via FTP etc.) and just import the links to the images, but I haven't figured that one out either.

(The data (files) is not being replicated, just the images are replicated.)

7
  • Do you have a unique target setup in the mapping? If you don't, it will duplicate. Dec 20, 2011 at 21:42
  • Yes, both product import and the reference import have Unique Targets.... In this example I am using the supplied example files (csv, prod import and ref import). They are not overridden.
    – Mark
    Dec 20, 2011 at 21:51
  • Try deleting the import... if this is possible. you will see an option, delete items, on the import page (/import/whatever_your_importer is called) Dec 20, 2011 at 22:29
  • After re reading your issue... I see that you will continue to have this problem no matter what. It is looking at the image as its own image for that node. I am not aware of a way to check duplicates of a file field on an importer. I would recommend doing an import of the catalog and using the file name as a flat URL field instead of importing the file... then in your node you should use the field to reference the image library using a template suggestion (drupal.org/node/1089656) It is a bit hackish, but if you mind the duplicates that much.. its your best bet. Dec 21, 2011 at 0:46
  • I see two relevant issues that may help. drupal.org/node/1357934 discusses using a reference to the image instead of importing the image itself. drupal.org/node/1171114 was a feature request. You might want to post a support request in the feeds queue in addition to following those issues.
    – rfay
    Dec 21, 2011 at 16:47

3 Answers 3

1

I found a solution to this. What you need to do is to install the Media Feeds module.

In your CSV file there is a column called e.g. image and reference the image using public://myimage.png.

Then in your mapping delete the original image mapping and create a new image mapping. When you do this you will have a new option for the image mapping. Make sure you set the target configuration to "Source is exactly the filename".

No more duplicated images.

5
  • Shane - I'm trying to follow what you did here. One question do all the images have to the in the public folder first? Currently I am downloading the images from the url in the csv file in the feeds import process, and am getting duplicates that I don't want. Sep 25, 2013 at 15:49
  • Hi, in my particular case I had all the images the public folder, I didn't try this on a remote url in csv. Let me know if you came right. Oct 1, 2013 at 6:13
  • Shane - No it didn't work for me with the url in the csv. Still duplicates :( Oct 2, 2013 at 11:09
  • Tried. Does not work :( When importing it says things like "Failed to get the file object for public://0091.jpg." Jan 30, 2014 at 14:24
  • Hi, not sure why you don't get the same result but just to be sure, the "public://0091.jpg" must be inserted with no quotes and the image must already exist in your Public file system path which can be found at admin/config/media/file-system , in my case it was sites/default/files Jan 31, 2014 at 16:17
0

There is some movement to resolve this issue (still in dev right now):

Apparently the official way going forward (will not apply to 7.x-2.0-alpha8 without errors): "Allow user to choose the method of file handling" https://drupal.org/node/1171114

Alternatively, this patch will apply to 7.x-2.0-alpha8 but will not be committed: "Allow the reuse of existing file entities instead of creating new ones" https://drupal.org/node/2093829

0

After banging my head against this issue for a while, my best option was to stop importing images into the nodes as files, but rather using imagecache_external module to reference the external image url and generating image styles from there. The module adds an Imagecache External Image formatter that behaves just like a normal image formatter in views and node displays.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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