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:
<units> <unit> <unit_details> <images> <image> <uri> http://www.example.com/files/content/villa-102-1.jpg </uri> </image> <image> <uri> http://www.example.com/files/content/villa-102-2.jpg </uri> </image> </images> </unit_details> </unit> </units>
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.
- Is it possible to import images using the image URL from the XML file?
- 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
UPDATE:
I was able to import images using the CSV importer and the image URL, so this appears to be a problem with Xpath Parser.
UPDATE 2:
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; } }
Sponsored by SupremePR