0

You ever notice Google News has relevant images associated with its headlines?

How can I use WordPress to extract a featured image from an external webpage referenced in a blog post (or custom field)?

I'm open to any suggestions. I've seen this kind of functionality on a lot of web sites. There must be a way to do this with WP.

2
  • I'm not seeing anytning that addresses my question; If you do, could you post a link?
    – Richard
    Commented May 16, 2012 at 23:46
  • Have you found a solution for this one?
    – brasofilo
    Commented Nov 27, 2012 at 17:38

1 Answer 1

1

Found some plugins that may (or not) match your requirements. Using this query string in the repository.

But, there's one (WP-SnapAvatar) that although doesn't address the particulars, consists in a little and very interesting function, that I'll reproduce here:

/*
Plugin Name: WP-SnapAvatar
Version: 1.0
Plugin URI: http://darkx-studios.com/
Description: This plugin puts the commentor's website screenshot where there is no gravatar.
Author: Neacsu Alexandru
Author URI: http://darkx-studios.com
Copyright (c) 2008
Released under the GPL license
http://www.gnu.org/licenses/gpl.txt
*/

function site_avatar_hook($baseCode) {
    $AutorUrl = get_comment_author_url();
    $PictureLink = "http://images.websnapr.com/?url=$AutorUrl";

    preg_match('@http://[^"\']+["\']@',$baseCode,$newSrc);
    $newSrc = $newSrc[0];

    if(trim($AutorUrl)){
        $httpSrc = substr($newSrc,0,strlen($newSrc) - 1) . "&nocatch=" . rand(10,100) ."&default=" . $PictureLink;
        $newAvatar=preg_replace('@src=(["\'])http://[^"\']+["\']@',"src='" . $httpSrc . "'",$baseCode);
    } else {
        $newAvatar = $baseCode; 
    }
    echo $newAvatar;
}

add_filter('get_avatar','site_avatar_hook',5,4);

For what you ask, I think that a combination of WP-SnapAvatar and this other one (Link Indication) would do the job.

But, I won't get into that otherwise I end up writing a new plugin :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.