• I am using the catch_that_image() function that is floating all over the internet to pull the first image in a post and use it as a thumbnail. Here is my exact code, for reference:

    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)){ //Defines a default image
        $first_img = get_bloginfo('template_directory') . '/images/noThumb.jpg"';
      }
      return $first_img;
    }

    Currently, I have to force the size of the image that is displayed by using CSS. Is there any way to change things so it uses the thumbnail sized image that I have defined? I figure that would drastically help reduce load times.

    I have tried other methods of pulling the images, but I haven’t had the best luck. None of them were actually pulling images :/

  • The topic ‘Defining the image size of dynamically pulled first image’ is closed to new replies.