If the $page_url in feeds_imagegrabber_feeds_set_target($node, $target, $page_url) is empty, FIG still goes through the process of validating etc, eventually firing a watchdog message "Input to field was not a valid URL".

Would it be ok to bail out earlier?

The reason this comes up for me is a very particular use case, but logically I think it still makes sense.

In my case many of the feed items will have a default image if nothing better is available. If I'd just let feeds and FIG do its thing, I would end up with thousands of copies of the same image. Hence I check for this default image in hook_feeds_after_parse() and replace the default image with an empty string. Since imagefield gives the option to have its own default image, this works well.

But I get a lot of unnecessary watchdog writes from this and FIG does more work than it needs to. Mini patch follows...

CommentFileSizeAuthor
#1 bail_if_url_empty-1082128-1.patch881 bytesnicolash

Comments

nicolash’s picture

StatusFileSize
new881 bytes
publicmind’s picture

I have no problem, but can you explain why is $page_url empty? I would rather replace it with valid_url($page_url), works for you?

nicolash’s picture

Hm, it's been a while since I tinkered with this. But isn't it quite possible to be empty for items in a feed in general? The feed I used at the time had only an image for about 1 in 5 items....and it seems to be unnecessary to check whether something that's empty is a valid URL. But up to you, of course...

rooby’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Since the Drupal 6 version is no longer supported I'm closing this.

For Drupal 7 though, hopefully the patch in #2244833: Image Grabber doesn't work with latest version of Feeds will do what you were trying to achieve here.

rooby’s picture

Also maybe of relevance is #1814774: Ignore default image