0
votes

I'm importing multiple articles from another site which contain images. I'd like the featured images in these articles to be the featured images on my Drupal site. In order to do this, I've downloaded all the images from that site and uplaoded them into my Drupal image directory at /public_html/sites/default/files/field/image.

I'm importing a CSV full of data from the other site, and in my field_image URL column, I've formatted it as "field/image/imagename.jpg". It's the correct name, but it's not being imported. I'm wondering:

  1. if I'm using the right path.
  2. if I'm using the appropriate assignment to the correct field.
  3. if it's possible to import the URL in the way I'm doing it.

I've tried assigning it to other fields, adjusting the URL, seeing if there's more information I need to add to the image by looking at the file I upload manually, but haven't found the answer.

I've looked around for an answer but couldn't find one. I'd appreciate any help you could give.

Thanks! Brendan

1

1 Answers

0
votes

In Drupal, every file has its own entry in the files table and then its id gets associated with the node. So for example, if you have an article content type with the field name "field_image" then node files stored in the table "field_data_field_image" with a reference of "fid" and "nid". When you render a node Drupal pulls the associated file data based on the "fid" from the files table.

So if you are using a custom script to import articles, I would suggest:

  1. First, look into the files table entries and make sure you have a fid for each file before adding the node.
  2. Once you have the fid,prepare your article node array containing the fid info and run the node_save() to save the node with file information.

Hope that will help!