0
votes

I can see that in my uploads folder all the images I have uploaded into posts have the 4 different sizes.

I have no featured image set for posts but I want to get the thumbnail size to display on my front page.

I have tried putting the_post_thumbnail(); in the loop but nothing is displayed.

Am I missing something? Is there another way to grab a thumbnail size of an image that has been put inside of the post?

Currently I use a catch the image function to grab the first image in the post and display it on the front page with this code, can this be edited to get that thumbnail image?

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];
    //$first_img = substr($first_img, 0, -4);  

    if(empty($first_img)){ //Defines a default image
    $first_img = bloginfo('template_directory');
    $first_img .= "/images/default.png";
    }
     return $first_img;
}

Thanks

1

1 Answers

0
votes

the_post_thumbnail displays featured image from the post, so if you haven't set any, it displays nothing.