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.
Pingback: Drupal: Feeds Image Grabber | Public Mind
Pingback: Tutorial for FeedAPI Image Grabber | Public Mind
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,
Okay, I might be a little confused about what you can do with this module.
I’m parsing an XML file with the Feeds module and I would like to grab an image.
From something like this…
Will this not work? Right now its not working, although I have used this feature successfully for non-xml feeds in the same site.
I am not sure about what are trying to do, open up a support request in the issue queue for the module here: http://drupal.org/node/add/project-issue/feeds_imagegrabber
Regards,
Oh, hahah – I guess it cut out the example XML I put right after “something like this..”, yeah I’ll head over to the issue que.
I am sure this is a great article.
for now , I still can not import the images from feeds. here is the feed:
http://api.flickr.com/services/feeds/groups_pool.gne?id=48889079722@N01&lang=en-us&format=atom
and then what is the ID or CLASS for “Search for an image between the tag which is identified by” ?
can you help me ?
Just to confirm, have you looked here: http://publicmind.in/blog/tutorial-for-feedapi-imagegrabber/#tag-options
yes, I looked that also, but the example is the HTML code , and can find the tag name easily, but this is a feed, so how can I get the tag name?
You need to find the tag CLASS/ID in the HTML code only. You should look at the entries imported by this feed, visit the original URL to which one of the feed item points to (http://www.flickr.com/photos/crumbs/5345566170/in/pool-48889079722@N01) and then find the ID/CLASS of the entity which you think will always contain the image you require.
Regards,
Hi,
I am using the Feeds module to import content from a CSV file (not from a Feed) using the “File upload” fetcher. Can FIG be used in that context? I already mapped an image (FIG) field in the Node processor mappings but I don’t see the FIG config form as shown above in your tutorial.
Thanks!
Of course, FIG can be used whatever fetcher you are using as long as the feed items are URL’s to some original article from where it can fetch images. If you are not seeing the FIG config form, please open an issue in the support queue with more details.
Thanks,
I am trying to implement this module for the Feeds module, in order to grab multiple images via xml. This looks like the solution to my problem.
Unfortunately, after mapping everything, etc… I don’t see this form when creating a field.
“Feeds Image Grabber Settings:”
Any clues would be most excellent, ’cause this looks like the hotfire.
Do you know if there will be FIG for Drupal 7?
A little late, but you may have already noticed the D7 release of FIG.
Thanks,
Hi, everyone!
Maybe i do something wrong, but i don’t saw images in imported nodes.
FileField Paths is required for image import?
All that i do, i show on http://drupal.org/node/1304446
See http://drupal.org/node/1304446#comment-5177394
Hi I posted a question at drupal but there was no reply so I am hoping I can get some help here. Whenever I delete existing nodes after the first import and I do the import again .. I will get a warning like this
Warning message
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘public://feeds_images/kim-kardashian-with-bangs_244x362.jpg’ for key ‘uri’
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘public://feeds_images/kayte-walsh-and-kelsey-grammer-photograph_’ for key ‘uri’
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘public://feeds_images/kate-major-mugshot_301x379.png’ for key ‘uri’
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘public://feeds_images/britney-spears-management-team_517x283.jpg’ for key ‘uri’
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘public://feeds_images/colbertromney_478x264.jpg’ for key ‘uri’
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘public://feeds_images/lana-del-ray-video-games-saturday-night-li’ for key ‘uri’
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘public://feeds_images/laura-kaeppeler-vote-for-me_450x254.jpg’ for key ‘uri’
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘public://feeds_images/joe-paterno-pic_474x332.jpg’ for key ‘uri’
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘public://feeds_images/newt-gingrich-ad-mitt-romney-will-say-anth’ for key ‘uri’
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘public://feeds_images/mr-worldwide_344x471.jpg’ for key ‘uri’
I have deleted all the existing images before I import again but I still get this error everytime.
> Now, you must go to the mapping settings for the Node Processor of the Feed Importer
If anyone is wondering where to find the Mapper, it’s at admin/structure/feeds/feed/mapping.
One needs to go to Structure -> Feeds Importers and click on “Override” of the “Feed” importer.
Override will become Edit after override.
Please consider adding this instructions in the original article.
Greetings.
Giovanni
Thank you, Giovanni, I was tearing my hair out trying to find this!
1.Installed feeds+Feeds XPath Parser along with feeds image grabber.
2.Already having a content type with the following fields Title, Category, Option, Image, Type(a drop down).
3.Since i am parsing XML i am using the module Feeds Xpath Parser and in “Select a parser” XPath XML parser – Parse XML using XPath.”
4.Having a “Plain text” Text format and the content type “my_content_type”.
(Now i went to my_content_type i couldn’t find anything for FIG settings)
5.Comes to mapping “Select a source” “Select a target” – pathparser:0 Title
xpathparser:1 Category
xpathparser:2 Option
xpathparser:3 Image (FIG)
…………………………………..
…………………………………..
6. Context – //item, Title – title , field_category -category, field_option – option, field_image – image
7.Here goes my XML
ABC Electronics
Home first column – left
yes
http://xyz/sites/default/files/field/image/pa.jpg
8.It says 1 Node created.
9.When i saw the node i can see that the picture is not present there.
10.And still now i didn’t get any settings for FIG in the content type associated with this particular feed.
Some one please help me where i am doing the mistake.
The Feeds Image Grabber Settings are located at admin/config/feeds_imagegrabber. This held me up for a few hours because I didn’t see a config options on the module page.
Would be nice if there was an accompanying input filter which could swap out the url’s for the grabbed external images with the resulting local urls.
I do not see settings
http://joxi.ru/GdomVIwyTJDIAtfj-6g
Feeds Image Grabber 7.x-1.0-alpha2+2-dev
+
Feeds 7.x-2.0-alpha8
I haven’t been actively working on the module lately, these settings may have changed since this was posted. Please reach out on the drupal forum for further help.
The module dont work 🙁
I had to go do:
admin/config/content/feeds_imagegrabber