Changeset 896

Show
Ignore:
Timestamp:
04/24/08 10:22:17 (9 months ago)
Author:
bastnic
Message:

fixed #559 : parameter on background and #560 for max{width/heght}, p=Kevin Lepeltier

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0.x/lib/jelix/CREDITS

    r887 r896  
    9393 
    9494Kévin Lepeltier (aka Lipki) 
    95  - plugin image for jtpl (#474, #502
     95 - plugin image for jtpl (#474, #502, #559, #560
    9696 - bug fixed in firebug support (#500) 
    9797 
  • branches/1.0.x/lib/jelix/CREDITS

    r887 r896  
    9393 
    9494Kévin Lepeltier (aka Lipki) 
    95  - plugin image for jtpl (#474, #502
     95 - plugin image for jtpl (#474, #502, #559, #560
    9696 - bug fixed in firebug support (#500) 
    9797 
  • branches/1.0.x/lib/jelix/CREDITS

    r887 r896  
    9393 
    9494Kévin Lepeltier (aka Lipki) 
    95  - plugin image for jtpl (#474, #502
     95 - plugin image for jtpl (#474, #502, #559, #560
    9696 - bug fixed in firebug support (#500) 
    9797 
  • branches/1.0.x/lib/jelix/CREDITS

    r887 r896  
    9393 
    9494Kévin Lepeltier (aka Lipki) 
    95  - plugin image for jtpl (#474, #502
     95 - plugin image for jtpl (#474, #502, #559, #560
    9696 - bug fixed in firebug support (#500) 
    9797 
  • branches/1.0.x/lib/jelix/plugins/tpl/html/function.image.php

    r882 r896  
    1010 
    1111/** 
     12 * image plugin :  write the url corresponding to the image 
     13 *  
    1214 * Add a link to the image, 
    1315 * The image is resized, and cached 
     
    1820 * width :uint 
    1921 * height :uint 
     22 * maxwidth :uint only with maxheight 
     23 * maxheight :uint only with maxwidth 
    2024 * zoom 1-100 
    2125 * omo :boolean 
     
    3034 * sopacity :uint 
    3135 * scolor #000000 :string 
     36 * background #000000 :string 
    3237 * 
    3338 * gif   -> image/gif 
     
    4045 * png   -> image/png 
    4146 * other -> image/png 
    42  */ 
    43  
    44 /** 
    45  * image plugin :  write the url corresponding to the image 
    4647 * 
    4748 * @param jTpl $tpl template engine 
     
    6162        && strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE') !== false 
    6263        && strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE 7') === false) { 
    63         $params['background'] = array(255, 255, 255)
     64        $params['background'] = '#ffffff'
    6465    } 
    6566     
     
    8283    // Cache and make changes if necessary. 
    8384    if( is_file($origine_path) && !is_file($cache_path) ) { 
    84         $att = array('width'=>'', 'height'=>'', 'zoom'=>'', 'alignh'=>'', 'alignv'=>'', 'ext'=>'', 'quality'=>'', 'shadow'=>''); 
     85        $att = array('width'=>'', 'height'=>'', 'maxwidth'=>'', 'maxheight'=>'', 'zoom'=>'', 'alignh'=>'', 'alignv'=>'', 'ext'=>'', 'quality'=>'', 'shadow'=>''); 
    8586        if( count(array_intersect_key($params, $att)) ) 
    8687            jtpl_function_html_image_inCache($src, $cachename, $params); 
     
    9596        $att['src'] = $origine_www; 
    9697        $att['style'] = empty($att['style'])?'':$att['style']; 
    97         if( !empty($params['width']) )     $att['style'] .= 'width: '.$params['width'].'px;'; 
    98         if( !empty($params['height']) ) $att['style'] .= 'height: '.$params['height'].'px;'; 
     98        if( !empty($params['width']) )             $att['style'] .= 'width: '.$params['width'].'px;'; 
     99        else if( !empty($params['maxwidth']) )     $att['style'] .= 'width: '.$params['maxwidth'].'px;'; 
     100        if( !empty($params['height']) )            $att['style'] .= 'height: '.$params['height'].'px;'; 
     101        else if( !empty($params['maxheight']) )    $att['style'] .= 'height: '.$params['maxheight'].'px;'; 
    99102    } else 
    100103        $att['src'] = $cache_www; 
     
    131134        case 'image/x-xpixmap'       : $image = imagecreatefromxpm($origine_www); break; 
    132135        default                      : return ; 
     136    } 
     137     
     138    if(!empty($array['maxwidth']) && !empty($array['maxheight'])) { 
     139         
     140        $rapy = imagesy($image)/$array['maxwidth']; 
     141        $rapx = imagesx($image)/$array['maxheight']; 
     142         
     143        if( $rapy > $rapx ) { 
     144            $array['height'] = $array['maxheight']; 
     145            $array['width'] = imagesx($image)/$rapy; 
     146        } else { 
     147            $array['width'] = $array['maxwidth']; 
     148            $array['height'] = imagesy($image)/$rapx; 
     149        } 
    133150    } 
    134151     
     
    193210    // Background 
    194211    if( !empty($array['background']) ) { 
     212        $array['background'] = str_replace('#', '', $array['background']); 
     213        $rgb = array(0,0,0); 
     214        for ($x=0;$x<3;$x++) $rgb[$x] = hexdec(substr($array['background'],(2*$x),2)); 
    195215        $fond = imagecreatetruecolor(imagesx($image), imagesy($image)); 
    196         imagefill( $fond, 0, 0, imagecolorallocate( $fond, 255, 255, 255) ); 
     216        imagefill( $fond, 0, 0, imagecolorallocate( $fond, $rgb[0], $rgb[1], $rgb[2]) ); 
    197217        imagecopy( $fond, $image, 0, 0, 0, 0, imagesx($image), imagesy($image)); 
    198218        $image = $fond; 
  • branches/1.0.x/lib/jelix/plugins/tpl/html/function.image.php

    r882 r896  
    1010 
    1111/** 
     12 * image plugin :  write the url corresponding to the image 
     13 *  
    1214 * Add a link to the image, 
    1315 * The image is resized, and cached 
     
    1820 * width :uint 
    1921 * height :uint 
     22 * maxwidth :uint only with maxheight 
     23 * maxheight :uint only with maxwidth 
    2024 * zoom 1-100 
    2125 * omo :boolean 
     
    3034 * sopacity :uint 
    3135 * scolor #000000 :string 
     36 * background #000000 :string 
    3237 * 
    3338 * gif   -> image/gif 
     
    4045 * png   -> image/png 
    4146 * other -> image/png 
    42  */ 
    43  
    44 /** 
    45  * image plugin :  write the url corresponding to the image 
    4647 * 
    4748 * @param jTpl $tpl template engine 
     
    6162        && strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE') !== false 
    6263        && strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE 7') === false) { 
    63         $params['background'] = array(255, 255, 255)
     64        $params['background'] = '#ffffff'
    6465    } 
    6566     
     
    8283    // Cache and make changes if necessary. 
    8384    if( is_file($origine_path) && !is_file($cache_path) ) { 
    84         $att = array('width'=>'', 'height'=>'', 'zoom'=>'', 'alignh'=>'', 'alignv'=>'', 'ext'=>'', 'quality'=>'', 'shadow'=>''); 
     85        $att = array('width'=>'', 'height'=>'', 'maxwidth'=>'', 'maxheight'=>'', 'zoom'=>'', 'alignh'=>'', 'alignv'=>'', 'ext'=>'', 'quality'=>'', 'shadow'=>''); 
    8586        if( count(array_intersect_key($params, $att)) ) 
    8687            jtpl_function_html_image_inCache($src, $cachename, $params); 
     
    9596        $att['src'] = $origine_www; 
    9697        $att['style'] = empty($att['style'])?'':$att['style']; 
    97         if( !empty($params['width']) )     $att['style'] .= 'width: '.$params['width'].'px;'; 
    98         if( !empty($params['height']) ) $att['style'] .= 'height: '.$params['height'].'px;'; 
     98        if( !empty($params['width']) )             $att['style'] .= 'width: '.$params['width'].'px;'; 
     99        else if( !empty($params['maxwidth']) )     $att['style'] .= 'width: '.$params['maxwidth'].'px;'; 
     100        if( !empty($params['height']) )            $att['style'] .= 'height: '.$params['height'].'px;'; 
     101        else if( !empty($params['maxheight']) )    $att['style'] .= 'height: '.$params['maxheight'].'px;'; 
    99102    } else 
    100103        $att['src'] = $cache_www; 
     
    131134        case 'image/x-xpixmap'       : $image = imagecreatefromxpm($origine_www); break; 
    132135        default                      : return ; 
     136    } 
     137     
     138    if(!empty($array['maxwidth']) && !empty($array['maxheight'])) { 
     139         
     140        $rapy = imagesy($image)/$array['maxwidth']; 
     141        $rapx = imagesx($image)/$array['maxheight']; 
     142         
     143        if( $rapy > $rapx ) { 
     144            $array['height'] = $array['maxheight']; 
     145            $array['width'] = imagesx($image)/$rapy; 
     146        } else { 
     147            $array['width'] = $array['maxwidth']; 
     148            $array['height'] = imagesy($image)/$rapx; 
     149        } 
    133150    } 
    134151     
     
    193210    // Background 
    194211    if( !empty($array['background']) ) { 
     212        $array['background'] = str_replace('#', '', $array['background']); 
     213        $rgb = array(0,0,0); 
     214        for ($x=0;$x<3;$x++) $rgb[$x] = hexdec(substr($array['background'],(2*$x),2)); 
    195215        $fond = imagecreatetruecolor(imagesx($image), imagesy($image)); 
    196         imagefill( $fond, 0, 0, imagecolorallocate( $fond, 255, 255, 255) ); 
     216        imagefill( $fond, 0, 0, imagecolorallocate( $fond, $rgb[0], $rgb[1], $rgb[2]) ); 
    197217        imagecopy( $fond, $image, 0, 0, 0, 0, imagesx($image), imagesy($image)); 
    198218        $image = $fond; 
  • branches/1.0.x/lib/jelix/plugins/tpl/html/function.image.php

    r882 r896  
    1010 
    1111/** 
     12 * image plugin :  write the url corresponding to the image 
     13 *  
    1214 * Add a link to the image, 
    1315 * The image is resized, and cached 
     
    1820 * width :uint 
    1921 * height :uint 
     22 * maxwidth :uint only with maxheight 
     23 * maxheight :uint only with maxwidth 
    2024 * zoom 1-100 
    2125 * omo :boolean 
     
    3034 * sopacity :uint 
    3135 * scolor #000000 :string 
     36 * background #000000 :string 
    3237 * 
    3338 * gif   -> image/gif 
     
    4045 * png   -> image/png 
    4146 * other -> image/png 
    42  */ 
    43  
    44 /** 
    45  * image plugin :  write the url corresponding to the image 
    4647 * 
    4748 * @param jTpl $tpl template engine 
     
    6162        && strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE') !== false 
    6263        && strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE 7') === false) { 
    63         $params['background'] = array(255, 255, 255)
     64        $params['background'] = '#ffffff'
    6465    } 
    6566     
     
    8283    // Cache and make changes if necessary. 
    8384    if( is_file($origine_path) && !is_file($cache_path) ) { 
    84         $att = array('width'=>'', 'height'=>'', 'zoom'=>'', 'alignh'=>'', 'alignv'=>'', 'ext'=>'', 'quality'=>'', 'shadow'=>''); 
     85        $att = array('width'=>'', 'height'=>'', 'maxwidth'=>'', 'maxheight'=>'', 'zoom'=>'', 'alignh'=>'', 'alignv'=>'', 'ext'=>'', 'quality'=>'', 'shadow'=>''); 
    8586        if( count(array_intersect_key($params, $att)) ) 
    8687            jtpl_function_html_image_inCache($src, $cachename, $params); 
     
    9596        $att['src'] = $origine_www; 
    9697        $att['style'] = empty($att['style'])?'':$att['style']; 
    97         if( !empty($params['width']) )     $att['style'] .= 'width: '.$params['width'].'px;'; 
    98         if( !empty($params['height']) ) $att['style'] .= 'height: '.$params['height'].'px;'; 
     98        if( !empty($params['width']) )             $att['style'] .= 'width: '.$params['width'].'px;'; 
     99        else if( !empty($params['maxwidth']) )     $att['style'] .= 'width: '.$params['maxwidth'].'px;'; 
     100        if( !empty($params['height']) )            $att['style'] .= 'height: '.$params['height'].'px;'; 
     101        else if( !empty($params['maxheight']) )    $att['style'] .= 'height: '.$params['maxheight'].'px;'; 
    99102    } else 
    100103        $att['src'] = $cache_www; 
     
    131134        case 'image/x-xpixmap'       : $image = imagecreatefromxpm($origine_www); break; 
    132135        default                      : return ; 
     136    } 
     137     
     138    if(!empty($array['maxwidth']) && !empty($array['maxheight'])) { 
     139         
     140        $rapy = imagesy($image)/$array['maxwidth']; 
     141        $rapx = imagesx($image)/$array['maxheight']; 
     142         
     143        if( $rapy > $rapx ) { 
     144            $array['height'] = $array['maxheight']; 
     145            $array['width'] = imagesx($image)/$rapy; 
     146        } else { 
     147            $array['width'] = $array['maxwidth']; 
     148            $array['height'] = imagesy($image)/$rapx; 
     149        } 
    133150    } 
    134151     
     
    193210    // Background 
    194211    if( !empty($array['background']) ) { 
     212        $array['background'] = str_replace('#', '', $array['background']); 
     213        $rgb = array(0,0,0); 
     214        for ($x=0;$x<3;$x++) $rgb[$x] = hexdec(substr($array['background'],(2*$x),2)); 
    195215        $fond = imagecreatetruecolor(imagesx($image), imagesy($image)); 
    196         imagefill( $fond, 0, 0, imagecolorallocate( $fond, 255, 255, 255) ); 
     216        imagefill( $fond, 0, 0, imagecolorallocate( $fond, $rgb[0], $rgb[1], $rgb[2]) ); 
    197217        imagecopy( $fond, $image, 0, 0, 0, 0, imagesx($image), imagesy($image)); 
    198218        $image = $fond; 
  • branches/1.0.x/lib/jelix/plugins/tpl/html/function.image.php

    r882 r896  
    1010 
    1111/** 
     12 * image plugin :  write the url corresponding to the image 
     13 *  
    1214 * Add a link to the image, 
    1315 * The image is resized, and cached 
     
    1820 * width :uint 
    1921 * height :uint 
     22 * maxwidth :uint only with maxheight 
     23 * maxheight :uint only with maxwidth 
    2024 * zoom 1-100 
    2125 * omo :boolean 
     
    3034 * sopacity :uint 
    3135 * scolor #000000 :string 
     36 * background #000000 :string 
    3237 * 
    3338 * gif   -> image/gif 
     
    4045 * png   -> image/png 
    4146 * other -> image/png 
    42  */ 
    43  
    44 /** 
    45  * image plugin :  write the url corresponding to the image 
    4647 * 
    4748 * @param jTpl $tpl template engine 
     
    6162        && strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE') !== false 
    6263        && strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE 7') === false) { 
    63         $params['background'] = array(255, 255, 255)
     64        $params['background'] = '#ffffff'
    6465    } 
    6566     
     
    8283    // Cache and make changes if necessary. 
    8384    if( is_file($origine_path) && !is_file($cache_path) ) { 
    84         $att = array('width'=>'', 'height'=>'', 'zoom'=>'', 'alignh'=>'', 'alignv'=>'', 'ext'=>'', 'quality'=>'', 'shadow'=>''); 
     85        $att = array('width'=>'', 'height'=>'', 'maxwidth'=>'', 'maxheight'=>'', 'zoom'=>'', 'alignh'=>'', 'alignv'=>'', 'ext'=>'', 'quality'=>'', 'shadow'=>''); 
    8586        if( count(array_intersect_key($params, $att)) ) 
    8687            jtpl_function_html_image_inCache($src, $cachename, $params); 
     
    9596        $att['src'] = $origine_www; 
    9697        $att['style'] = empty($att['style'])?'':$att['style']; 
    97         if( !empty($params['width']) )     $att['style'] .= 'width: '.$params['width'].'px;'; 
    98         if( !empty($params['height']) ) $att['style'] .= 'height: '.$params['height'].'px;'; 
     98        if( !empty($params['width']) )             $att['style'] .= 'width: '.$params['width'].'px;'; 
     99        else if( !empty($params['maxwidth']) )     $att['style'] .= 'width: '.$params['maxwidth'].'px;'; 
     100        if( !empty($params['height']) )            $att['style'] .= 'height: '.$params['height'].'px;'; 
     101        else if( !empty($params['maxheight']) )    $att['style'] .= 'height: '.$params['maxheight'].'px;'; 
    99102    } else 
    100103        $att['src'] = $cache_www; 
     
    131134        case 'image/x-xpixmap'       : $image = imagecreatefromxpm($origine_www); break; 
    132135        default                      : return ; 
     136    } 
     137     
     138    if(!empty($array['maxwidth']) && !empty($array['maxheight'])) { 
     139         
     140        $rapy = imagesy($image)/$array['maxwidth']; 
     141        $rapx = imagesx($image)/$array['maxheight']; 
     142         
     143        if( $rapy > $rapx ) { 
     144            $array['height'] = $array['maxheight']; 
     145            $array['width'] = imagesx($image)/$rapy; 
     146        } else { 
     147            $array['width'] = $array['maxwidth']; 
     148            $array['height'] = imagesy($image)/$rapx; 
     149        } 
    133150    } 
    134151     
     
    193210    // Background 
    194211    if( !empty($array['background']) ) { 
     212        $array['background'] = str_replace('#', '', $array['background']); 
     213        $rgb = array(0,0,0); 
     214        for ($x=0;$x<3;$x++) $rgb[$x] = hexdec(substr($array['background'],(2*$x),2)); 
    195215        $fond = imagecreatetruecolor(imagesx($image), imagesy($image)); 
    196         imagefill( $fond, 0, 0, imagecolorallocate( $fond, 255, 255, 255) ); 
     216        imagefill( $fond, 0, 0, imagecolorallocate( $fond, $rgb[0], $rgb[1], $rgb[2]) ); 
    197217        imagecopy( $fond, $image, 0, 0, 0, 0, imagesx($image), imagesy($image)); 
    198218        $image = $fond; 
Download in other formats: Unified Diff Zip Archive