Feeds Image Grabber (FIG) was released on 3rd March, and currently supports the following features:
- Automatically downloads and attaches image to the node created by Feeds module.
- Configurable XPath of the desired image location on the webpage of the feed item on per feed basis (using element’s id or CSS class).
- Support for FileField Paths module.
- Configurable maximum image size.
- Configurable minimum and maximum image resolutions.
In this post, I will briefly demonstrate how to configure the settings for FIG to efficiently grab images for feed items.
Image Field Settings:
Feeds module will create nodes from feed-items of content type as chosen in the FeedsNodeProcessor settings. FIG will store the image grabbed in an image field attached to the node of this content type. Therefore, you must add an image field to this content type. For example, if the content type of feed-items is story, you need to go to admin > content types > story > manage fields and add a field of type File and widget Image. (http://drupal.org/node/609628)
Configure the settings of the image field, such as extensions, minimum and maximum resolution, maximum size, etc. While grabbing the image, FIG will automatically take into consideration the settings of the image field to which the downloaded image will be mapped.
Mapping Settings:
Now, you must go to the mapping settings for the Node Processor of the Feed Importer and map Item URL (Link) to one of the available imagefields which are appended by “(FIG)“.
Feeds Image Grabber Settings:
After enabling FIG and configuring the above settings, you will see the following additional form whenever you create or edit a feed.
Here is a brief explanation of the available fields:
- Enable Feeds Image Grabber: As the description says, check this box if you want FIG to download images of the feed items created by this feed.
- Search for an image between the tag identified by: It has been explained before here.
- Feeling Lucky: FIG will select the first image between the tag if the “yes” is selected, else will search for all the images to find the largest image between the tag.
- Execution time: FIG will take the selected percentage of maximum PHP execution time to grab image for each feed item. If images are not grabbed for some feed, try increasing this percentage to decrease errors due to network timeouts.
That is all. Once you click on import, you will get the feed item nodes along with the images. If images are not grabbed, here is a list of possible reasons,
- Timeout, try increasing the Execution time.
- Malformed HTML source.
- Validation failures (due to maximum size, minimum resolution, etc).
I am working on better error logging and reporting, so that you can know the reasons for sure.
Enjoy.
Related Posts:
- Feeds Image Grabber: http://publicmind.in/blog/drupal-feeds-image-grabber
- FIG project page (Download): http://drupal.org/project/feeds_imagegrabber










[...] Tutorials: http://publicmind.in/blog/tutorial-for-feeds-image-grabber [...]
[...] Tutorial for Feeds Image Grabber (FIG) published. (6 march 2010) [...]
good job, but I have a question is that the feeds didn’t released 7.X,but your plugin(feed image grabber)have been released 7.X
7.x of Feeds Image Grabber (FIG) just contains the common functions for parsing web pages, scraping images, saving files but it hasn’t been integrated with Feeds (as no 7.x exists for Feeds yet).
Agreed pretty awesome, but I’m looking to snag images right from the body of posts. Most feeds I’ve encountered we’re so nice about placing an image item right in them, though this module would be great for flickr feeds and even getting avatar images into a field for good display.
Here is some code I used to catch the first image in a post body.
Altered from this post intended for WordPress http://www.wprecipes.com/how-to-get-the-first-image-from-the-post-and-display-it
I’m using it for Drupal, and unfortunately I can’t post the real PREG here.
function retrofit_custom_catch_image($string) {
$first_img = ”;
$output= preg_match_all(‘ GO GET THE REAL PREG FROM THE POST ‘, $string, $matches);
$first_img = $matches[1][0];
if(empty($first_img)){ //Defines a default image
$first_img = “/images/default.jpg”;
}
return $first_img;
}
Hope I just made your day!
I agree that most of the feeds come with images inserted inside the body of the post or within an additional tag in the XML feed. Achieving the former, as you demonstrated, is relatively easy but mapping it to filefield/imagefield would require some extra efforts. I remember FeedAPI Scrapper used to do this with FeedAPI which, unfortunately, hasn’t been ported for Feeds yet. It scraped the body of the feed-item for any content recognized by a PREG or REGEX and mapped it to user-defined fields. Achieving the latter, according to me, would require a custom parser which can look for those extra tags in the XML feed.
Also, see http://drupal.org/node/783694#comment-2900110
Cheers,
Looks like we’re talking to each other in two threads now
I created that issue. Thanks for the info. I’ll continue there.
I installed your module and have followed the directions up to the bit about the mapping but “photo (FIG)” isn’t showing up in the target list? Any ideas?
see http://drupal.org/node/805622#comment-2996366
Cheers,