Resize image as post thumb on home page wordpress

Discussion in 'WordPress' started by mixtaka, Mar 15, 2010.

  1. #1
    i use the theme - junkie channel, on my wordpress blog, this is the official site of the theme : http://www.theme-junkie.com/themes/channel/

    In this theme, the auto post thumbnail is already activated but the image will crop not resize, this post thumbnail work only on internal images, they did not accept external images, and my blog - http://www.movieflake.com/ have external images almost all posts.

    i also put this question in wordpress official forum and they reply me, visit this- http://codex.wordpress.org/Function_...tachment_image , i visit it, but i did not understand anything,

    Now I use this script on funtion.php to retrieve first image of post on home page as an post thumbnail. the script will work on external images same as i want, but the post image will crop not resize. can anyone tell me what modification i do in this code, so the image will resize.
    im new in wordpress

    Code:

    // Retrieve the src of first image in a post
    function bm_extract_string($start, $end, $original) {
    $original = stristr($original, $start);
    $trimmed = stristr($original, $end);
    return substr($original, strlen($start), -strlen($trimmed));
    }
    function getFirstImage() {
    $content = get_the_content();
    $pic_string = bm_extract_string('src="','" ',$content);
    $imagesize = getimagesize($pic_string);
    list($width, $height, $type, $attr) = getimagesize($pic_string);
    $link = get_permalink();
    $title = get_the_title($post->post_title);
    echo '<a href="'.$link.'" style="background:url('.$pic_string.'); display:block; width:'.$width.'px; height:'.$height.'px;" title="'.$title.'"></a>';
    }
    
    Code (markup):
    than add this code on index.php

    Code:

      <?php getFirstImage(); ?>
    Code (markup):
    Thanks
     
    mixtaka, Mar 15, 2010 IP