I have a content type in Drupal 6 wiht a title and an image in an imagefield. I have exported the nodes to an xml file.
I made the same content type in Drupal 7 and want to import the nodes.
A record of my xml file from Drupal 6 is like this:

<nodes>
  <node>
    <Titel>Madese Boys</Titel>
    <Shirt>&lt;img  class="imagefield imagefield-field_verenigingsshirt" width="24" height="21" alt="" src="http://localhost/sites/default/files/made.gif?1301332564" /&gt;</Shirt>
    <Nid>35</Nid>
  </node><nodes>

The import works when I only choose the field "Titel".
When I add the field "Shirt" the import does not work, The images are in "http://localhost/sites/default/files/"

The xml output of two records of the contenttype in Drupal 7 is:

<?xml version="1.0" encoding="UTF-8" ?>
<nodes>
  <node>
    <Titel>Madese Boys</Titel>
    <Shirt>&lt;img typeof="foaf:Image" src="http://localhost/vvwd7/sites/default/files/made.gif" width="24" height="21" alt="" /&gt;</Shirt>
    <Nid>35</Nid>
  </node>
  <node>
    <Titel>Uno Animo</Titel>
    <Shirt>&lt;img typeof="foaf:Image" src="http://localhost/vvwd7/sites/default/files/unoanimo.gif" width="24" height="21" alt="" /&gt;</Shirt>
    <Nid>36</Nid>
  </node>
</nodes>

I added "FeedImportFilter::getProperty" to the filter and put 'src' on the second line function params

I get an error nr.8 on line 220 of modules\file\file.field.inc:
Trying to get property of non-object

Thanks for any help.

CommentFileSizeAuthor
#3 image-filter.png5.69 KBSorin Sarca

Comments

PvO’s picture

Issue summary: View changes

added Drupal 7 xml output of records of the content type and the filter FeedImportFilter::getProperty

PvO’s picture

Issue summary: View changes

added 'Drupal 6" on mentioning first time xml

Sorin Sarca’s picture

Hi,
You cannnot get src property because "img" is a content in "Shirt" tag (you must use < and > not &lt; and &gt;).
So, you have to replace all instances of &lt; with < and &gt; with >. Finally your xpath to src property will look something like Shirt/img/@src (don't forget that xml tags are case-sensitive) and then you can use ::getProperty in filters.

Instead of this:
<Shirt>&lt;img typeof="foaf:Image" src="http://localhost/vvwd7/sites/default/files/made.gif" width="24" height="21" alt="" /&gt;</Shirt>
use this:
<Shirt><img typeof="foaf:Image" src="http://localhost/vvwd7/sites/default/files/made.gif" width="24" height="21" alt="" /></Shirt>

Hope this helps you.

flymatic’s picture

Hi,
i have similar issue with display of images from my xml feed.My setup is drupal 7.10 clean installation and feed_import 2.2. I created content type with couple of fields - title, body ,image. Image field in content type is with field "image" and widget type of "image".
My xml file looks like this:

<item>
	<id>111</id>
	<title>Title 1</title>
	<body>Texte of the body</body>
	<image>http://remotedomain.com/files/imagename.jpg</image>
</item>

When i import only "title" and "body" fields everything works perfect. The problem arise when I try to map image field of element from my xml file.I did a couple of "trial and error" attempts, i added different filters to image field mapping, but with no luck.
I get an error 8 on line 220 of modules\file\file.field.inc:
Trying to get property of non-object
Could someone give me a hint or maybe I'm doing something wrong.

thanx

Sorin Sarca’s picture

StatusFileSize
new5.69 KB

Hi,
to save image you must use a filter for your field. Take a look at this example http://drupal.org/node/1360374#import-html.
This is for image field:

Finally we have to save image to field.
Add new filter named "Save image" with function name "FeedImportFilter::saveImage" and two params: [field] and public://field/image/

Feed Import Save Image Filter

flymatic’s picture

Thank you for your prompt response.
Now everything work fine:).
Thanks once again.

Sorin Sarca’s picture

Status: Active » Closed (fixed)
Sorin Sarca’s picture

Issue summary: View changes

added error 8