• Hello Fellow WordPressians,
    I wasn’t sure where to post this question so if theres a better place to post it please tell me.

    So I put in the php code for the Catchthatimage function in my plugins
    so I could grab the first image in my post to use as a small preview image.
    My issue however is that the preview window is often too small and the image that it catches is shrunk down and looks like garbage inside of it.
    I noticed there was a crop feature in the image managment part of the wordpress dashboard. Like it splits the image into original and thumbnail.

    Is there anyway to call on the cropped image (thumbnail) instead of the full image in the same way I use the Catchthatimage function?

    Sorry if I’m not articulating myself well. Please ask if there is any confusion in regard to my question.

    Your help is greatly appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • So I put in the php code for the Catchthatimage function in my plugins

    What Catchthatimage function? That’s not part of WordPress core.

    Thread Starter mot13

    (@mot13)

    oops! My mistake,
    I meant functions.php not plugins.
    Sorry.
    But heres what it looks like

    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 = bloginfo('template_directory');
        		$first_img .= "/images/default.png";
      		}
      		return $first_img;
    	}

    and this is how I evoke the function in the themes code

    <img src="<?php echo catch_that_image(); ?>" alt="<?php the_title(); ?>" width="770px" height="200px" class="featuredImage" />

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    So I’m wondering how I might get it to catch the thumbnail of the first image, rather than the entire image

    Thread Starter mot13

    (@mot13)

    Thanks Acrane,
    But its not exactly what I mean

    here’s my website, it may better illustrate what I mean
    kidtrash.com
    (The website is still largely broken so please ignore the mess)

    You see in the “latest comic” window in the right sidebar,
    I’d like for a cropped image of the image to appear there instead of
    the whole thing. Sort of like a preview

    Then I’d like for that image to link to the comics post.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Catch that image Function but with thumbnails’ is closed to new replies.