Ticket #560: image_proportion.diff
| File image_proportion.diff, 2.4 kB (added by Lipki, 9 months ago) |
|---|
-
function.image.php
old new 17 17 * alt :string 18 18 * width :uint 19 19 * height :uint 20 * maxwidth :uint only with maxheight 21 * maxheight :uint only with maxwidth 20 22 * zoom 1-100 21 23 * omo :boolean 22 24 * alignh [left|center|right|:int] … … 81 83 82 84 // Cache and make changes if necessary. 83 85 if( is_file($origine_path) && !is_file($cache_path) ) { 84 $att = array('width'=>'', 'height'=>'', ' zoom'=>'', 'alignh'=>'', 'alignv'=>'', 'ext'=>'', 'quality'=>'', 'shadow'=>'');86 $att = array('width'=>'', 'height'=>'', 'maxwidth'=>'', 'maxheight'=>'', 'zoom'=>'', 'alignh'=>'', 'alignv'=>'', 'ext'=>'', 'quality'=>'', 'shadow'=>''); 85 87 if( count(array_intersect_key($params, $att)) ) 86 88 jtpl_function_html_image_inCache($src, $cachename, $params); 87 89 } … … 94 96 if( !is_file($cache_path) ) { 95 97 $att['src'] = $origine_www; 96 98 $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;'; 99 if( !empty($params['width']) ) $att['style'] .= 'width: '.$params['width'].'px;'; 100 else if( !empty($params['maxwidth']) ) $att['style'] .= 'width: '.$params['maxwidth'].'px;'; 101 if( !empty($params['height']) ) $att['style'] .= 'height: '.$params['height'].'px;'; 102 else if( !empty($params['maxheight']) ) $att['style'] .= 'height: '.$params['maxheight'].'px;'; 99 103 } else 100 104 $att['src'] = $cache_www; 101 105 … … 132 136 default : return ; 133 137 } 134 138 139 if(!empty($array['maxwidth']) && !empty($array['maxheight'])) { 140 141 $rapy = imagesy($image)/$array['maxwidth']; 142 $rapx = imagesx($image)/$array['maxheight']; 143 144 if( $rapy > $rapx ) { 145 $array['height'] = $array['maxheight']; 146 $array['width'] = imagesx($image)/$rapy; 147 } else { 148 $array['width'] = $array['maxwidth']; 149 $array['height'] = imagesy($image)/$rapx; 150 } 151 } 152 135 153 if (!empty($array['width']) || !empty($array['height'])) { 136 154 137 155 $ancienimage = $image;
