Hi,
I'm working on a site and I'm trying to make it search through the images in the post to come up with a post thumbnail.
The thing is, when you add the image to the post while creating it, it picks the thumbnail straight away, but when you add an image after the post has been published, it doesn't change the already assigned default image.
Here is the code for the thumbnails:
// Get image attachment (sizes: thumbnail, medium, full)
function get_thumbnail($postid=0, $size='full') {
if ($postid<1)
$postid = get_the_ID();
$thumb_key = get_theme_mod('thumb_key');
if($thumb_key)
$thumb_key = $thumb_key;
else
$thumb_key = 'thumb';
$thumb = get_post_meta($postid, $thumb_key, TRUE); // Declare the custom field for the image
if ($thumb != null or $thumb != '') {
return $thumb;
} elseif ($images = get_children(array(
'post_parent' => $postid,
'post_type' => 'attachment',
'numberposts' => '1',
'post_mime_type' => 'image', ))) {
foreach($images as $image) {
$thumbnail=wp_get_attachment_image_src($image->ID, $size);
return $thumbnail[0];
}
} else {
return get_bloginfo ( 'stylesheet_directory' ).'/images/login-logo2.jpg';
}
}
And here is the website -> web.ugometrics.com.
Most of the posts with the issue have the "ugometrics" logo as the thumbnail, for your consideration.
Any ideas?
Thanks