I Need to Pull First image (external URL image) as Featured Image.

Posted in: Newspaper
Post count: 1

Added this function: (which works almost all the time)
function catch_that_image() {
global $post, $posts;
$first_img = ”;
ob_start();
ob_end_clean();
$output = preg_match_all(‘/<img.+src=[\'”]([^\'”]+)[\'”].*>/i’, $post->post_content, $matches);
$first_img = $matches[1][0];

if(empty($first_img)) {
$first_img = “/path/to/default.png”;
}
return $first_img;
}

And Added this to various loops, but still didn’t work:

if ( get_the_post_thumbnail($post_id) != ” ) {

echo ‘‘;
the_post_thumbnail();
echo ‘
‘;

} else {

echo ‘‘;
echo ‘<img src=”‘;
echo catch_that_image();
echo ‘” alt=”” />’;
echo ‘
‘;

}

Post count: 9544

WordPress can’t automatically generate thumb from external image or apply to featured slot.

We use the cheap plugin “auto post thumbnail PRO” found on Envato.

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newspaper’ is closed to new topics and replies.