• Hey

    When you upload a picture to the media library, WP generates a thumbnail (size set by you) that itself uses when you look inside your media library.

    Is there a way to extract that? I am using a catch-that-first-image-in-the-post function but I dont know PHP that well and I wanted to know if there is a better way to do it.

    The function I use is:

    function catch_that_image() {
      global $post, $posts;
      $first_img = '';
      $nothumb = get_bloginfo('template_directory');
      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 = "$nothumb/images/default.jpg";
      }
      return $first_img;
    }

    Can it be changed to load the thumbnail of the first image instead?
    Thanks in advance.

  • The topic ‘WP Admin thumbnails’ is closed to new replies.