2010-03-16 52 views

回答

0

我們修改了tep_image函數來接受-1,這意味着它只會輸出「高度」或「寬度」約束,但不能同時輸出。您可以根據自己的喜好進行修改,但您想查看tep_image的includes/functions/html_output.php()

// The HTML image wrapper function 
    function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') { 
    if ((empty($enter code heresrc) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false')) { 
     return false; 
    } 

    if($src=='images/') 
     $src='images/noimage.jpg'; 
// alt is added to the img tag even if it is null to prevent browsers from outputting 
// the image filename as default 
    $image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"'; 

    if (tep_not_null($alt)) { 
     $image .= ' title=" ' . tep_output_string($alt) . ' "'; 
    } 
     if(((int)$height==-1) && ((int)$width)==-1){ 
      $image .= ''; 
     }elseif((!empty($width) && ((int)$height)==-1)){ 
      $image .= ' width="' . tep_output_string($width) . '" '; 
     }elseif((!empty($height) && ((int)$width)==-1)){ 
      $image .= ' height="' . tep_output_string($height) . '" '; 
     }else{ 
      if ((CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height))) { 
       if ($image_size = @getimagesize($src)) { 
       if (empty($width) && tep_not_null($height)) { 
        $ratio = $height/$image_size[1]; 
        $width = intval($image_size[0] * $ratio); 
       } elseif (tep_not_null($width) && empty($height)) { 
        $ratio = $width/$image_size[0]; 
        $height = intval($image_size[1] * $ratio); 
       } elseif (empty($width) && empty($height)) { 
        $width = $image_size[0]; 
        $height = $image_size[1]; 
       } 
       } elseif (IMAGE_REQUIRED == 'false') { 
       return false; 
       } 
      } 
      if (tep_not_null($width) && tep_not_null($height)) { 
       $image .= ' wddidth="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"'; 
      } 
     } 

    if (tep_not_null($parameters)) $image .= ' ' . $parameters; 

    $image .= '>'; 

    return $image; 
    }