I need help on PHP please

saber210

Supreme Member
Joined
Sep 1, 2011
Messages
1,358
Reaction score
503
I have a gallery code that will resize the image to 255,xxx.. I really need to set the width to 330px.

I tried changing the 255 to 330, but it keeps resizing the images to 255px..

This is wordpress btw.

Code:
function wim_index($id){
    $img = get_bloginfo('wpurl').'/wp-content/uploads/thumbnail/'.$id.'2550.jpg';
    $sn = 0;
    $src_h = wim_exist($id, 255, 0);
    if($src_h > 0){
        return '<img src="'.$img.'" height="'.$src_h.'" />';
    }else{
        ob_start();
        ob_end_clean();
        $fpost = get_post($id);
        $content = $fpost->post_content;
        $output = preg_match_all('/\<img.+?src="(.+?)".*?\/>/is',$content,$matches ,PREG_SET_ORDER);
        $cnt = count( $matches );
        if($cnt>0){
            wim_delete($id, 255, 0);
            $args = resizeimg($id, $matches[0][1], 0, 255);
            $w = $args['width'];
            $h = $args['height'];
            wim_insert($id, $sn, $w, $h);
            return '<img src="'.$img.'" height="'.$h.'" />';
        }else{
            return false;
        }
    }
}

Thanks!
 
I have a gallery code that will resize the image to 255,xxx.. I really need to set the width to 330px.

I tried changing the 255 to 330, but it keeps resizing the images to 255px..

This is wordpress btw.

Code:
function wim_index($id){
    $img = get_bloginfo('wpurl').'/wp-content/uploads/thumbnail/'.$id.'2550.jpg';
    $sn = 0;
    $src_h = wim_exist($id, 255, 0);
    if($src_h > 0){
        return '<img src="'.$img.'" height="'.$src_h.'" />';
    }else{
        ob_start();
        ob_end_clean();
        $fpost = get_post($id);
        $content = $fpost->post_content;
        $output = preg_match_all('/\<img.+?src="(.+?)".*?\/>/is',$content,$matches ,PREG_SET_ORDER);
        $cnt = count( $matches );
        if($cnt>0){
            wim_delete($id, 255, 0);
            $args = resizeimg($id, $matches[0][1], 0, 255);
            $w = $args['width'];
            $h = $args['height'];
            wim_insert($id, $sn, $w, $h);
            return '<img src="'.$img.'" height="'.$h.'" />';
        }else{
            return false;
        }
    }
}

Thanks!

Try this out:
Code:
function wim_index($id){
    $img = get_bloginfo('wpurl').'/wp-content/uploads/thumbnail/'.$id.'2550.jpg';
    $sn = 0;
    $src_h = wim_exist($id, 255, 0);
    if($src_h > 0){
        return '<img src="'.$img.'" height="'.$src_h.'" width="330"/>';
    }else{
        ob_start();
        ob_end_clean();
        $fpost = get_post($id);
        $content = $fpost->post_content;
        $output = preg_match_all('/\<img.+?src="(.+?)".*?\/>/is',$content,$matches ,PREG_SET_ORDER);
        $cnt = count( $matches );
        if($cnt>0){
            wim_delete($id, 255, 0);
            $args = resizeimg($id, $matches[0][1], 0, 255);
            $w = $args['width'];
            $h = $args['height'];
            wim_insert($id, $sn, $w, $h);
            return '<img src="'.$img.'" height="'.$h.'" width="'.$w.'"/>';
        }else{
            return false;
        }
    }
}

I simply added the width attribute to the image.
 
Thanks, I already solved it.
 
Back
Top