Importing images into a multi-valued image field using image URLs from an XML file is not working for me. The Xpath Parser debug output shows the multiple image URLs being parsed correctly, but the images don't get imported. No problem with other ordinary fields.

The XML structure is:


The context is: //unit

The Xpath query for the image field is: unit_details/images/image/uri

I played around with the image grabber module for feeds, but it failed also - doesn't seem suited to this task.

  1. Is it possible to import images using the image URL from the XML file?
  2. Is it possible to import multiple images into a multi-valued image field?

I'm using Feeds version 6.x-1.0-beta12+18-dev, and Feeds Xpath Parser version 6.x-1.12


I was able to import images using the CSV importer and the image URL, so this appears to be a problem with Xpath Parser.


I'm seeing no errors in the dblog or the server log. That patch is for D7. The images do not show up in the node display, but the other fields do.

Looks like the "enclosure" error gets thrown if the local file name isn't in the right form, but I just have an external URL. As I mentioned above, the image with the same URL does get imported using the CSV parser, so it doesn't appear to be a problem with the Feeds module, just the Xpath Parser.

The relevant code in D6 (FeedsParser.inc) is:

       * @return
       *   A path pointing to a file containing the resource referenced by the
       *   enclosure. This method downloads the resource if it is not local. The
       *   file path must be considered temporary and is only valid for the current
       *   page load.
       * @todo Get file extension from mime_type.
       * @todo This is not concurrency safe.
      public function getFile() {
        if (empty($this->file) && $this->getValue()) {
          // Check if this enclosure contains a local file.
          if (!parse_url($this->getValue(), PHP_URL_SCHEME)) {
            if (file_check_location($this->getValue(), file_directory_path()) || file_check_location($this->getValue(), file_directory_temp())) {
              if (file_exists($this->getValue())) {
                $this->file = $this->getValue();
                return $this->file;
            throw new Exception(t('Invalid enclosure %enclosure', array('%enclosure' => $this->getValue())));
          $filename = basename($this->getValue());
          if (module_exists('transliteration')) {
            require_once drupal_get_path('module', 'transliteration') . '/transliteration.inc';
            $filename = transliteration_clean_filename($filename);
          $dest = file_destination(file_directory_temp() .'/'. $filename, FILE_EXISTS_RENAME);
          if (ini_get('allow_url_fopen')) {
            $this->file = copy($this->getValue(), $dest) ? $dest : 0;
          else {
            $this->file = file_save_data($this->getContent(), $dest);
          if ($this->file === 0) {
            throw new Exception(t('Cannot write content to %dest', array('%dest' => $dest)));
          $this->delete_file = TRUE;
        return $this->file;


1 Answer 1

  1. yes it's possible.

  2. Feeds is buggy sometimes.

Try this patch: http://drupal.org/node/1482530

Can you give more information about what isn't working? What errors are produced etc.

  • Hmm, can't put all the code in comments - have to edit original post again.
    – Jeff
    Commented Aug 24, 2012 at 11:59
  • 1
    Tried this in D7 and it throws the error: "Download of example.com/files/content/en-thailand-villa-102-1.jpg failed with code -1002." I can't find what component is responsible for that error code. cURL doesn't seem to have error codes like that. Tried forcing Feeds NOT to use cURL but it still fails. Think I'll file a bug report. D7 Feeds is still Alpha code, but the problem is likely the same as in D6. Puzzling though since importing the same URL using the CSV parser works ok.
    – Jeff
    Commented Aug 25, 2012 at 7:56
  • Might have something to do with permissions of your tmp directory.
    – mirzu
    Commented Aug 29, 2012 at 22:23
  • Can't be permissions since the CSV parser works ok with Feeds. Anyway, /tmp perms are 777.
    – Jeff
    Commented Aug 30, 2012 at 5:35
  • @Jeff I am facing the same issue with xpath parser. Are you able to get around this problem of images? It has been more than a year now.
    – jan
    Commented Jul 13, 2014 at 3:50

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.