I need help on PHP please

 

Results 1 to 4 of 4
I have a gallery code that will resize the image to 255,xxx.. I really need ...
  1. #1
    saber210's Avatar
    saber210 is offline Supreme Member
    Join Date
    Aug 2011
    Location
    -
    Posts
    1,218
    Thanks
    69
    Thanked 424 Times in 276 Posts

    Default I need help on PHP please

    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!




  2. #2
    teapear is offline Junior Member
    Join Date
    Feb 2009
    Posts
    182
    Thanks
    41
    Thanked 34 Times in 27 Posts

    Default Re: I need help on PHP please

    paste here your resizeimg code..

  3. #3
    solomayne's Avatar
    solomayne is offline Newbies
    Join Date
    Aug 2013
    Posts
    23
    Thanks
    51
    Thanked 9 Times in 9 Posts

    Default Re: I need help on PHP please

    Quote Originally Posted by saber210 View Post
    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.

  4. #4
    saber210's Avatar
    saber210 is offline Supreme Member
    Join Date
    Aug 2011
    Location
    -
    Posts
    1,218
    Thanks
    69
    Thanked 424 Times in 276 Posts

    Default Re: I need help on PHP please

    Thanks, I already solved it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




BlackHatWorld on Twitter BlackHatWorld on FaceBook


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101