- 01
 - 02
 - 03
 - 04
 - 05
 - 06
 - 07
 - 08
 - 09
 - 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
 
                        <?
 function ShowImage($strImage, $iMaxW=0, $iMaxH=0, $sParams=null, $strImageUrl="", $bPopup=false, $sPopupTitle=false, $iSizeWHTTP=0, $iSizeHHTTP=0)
 {
  global $DOCUMENT_ROOT, $DB;
  if(!($arImgParams = CFile::_GetImgParams($strImage, $iSizeWHTTP, $iSizeHHTTP)))
   return "";
  if($sParams === null || $sParams === false)
   $sParams = ' border="0" ';
  $iMaxW = intval($iMaxW);
  $iMaxH = intval($iMaxH);
  $strImage = htmlspecialchars($arImgParams["SRC"]);
  $intWidth = $arImgParams["WIDTH"];
  $intHeight = $arImgParams["HEIGHT"];
  $strAlt = $arImgParams["ALT"];
  if($sPopupTitle===false)
   $sPopupTitle=GetMessage("FILE_ENLARGE");
  $file_type = GetFileType($strImage);
  switch($file_type):
   case "FLASH":
    $iWidth = $intWidth;
    $iHeight = $intHeight;
    if($iMaxW>0 && $iMaxH>0 && ($intWidth > $iMaxW || $intHeight > $iMaxH))
    {
     $coeff = ($intWidth/$iMaxW > $intHeight/$iMaxH? $intWidth/$iMaxW : $intHeight/$iMaxH);
     $iWidth = intval(roundEx($intHeight/$coeff));
     $iHeight = intval(roundEx($intWidth/$coeff));
    }
    $strReturn = '
     <object
      classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000"
      codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
      id="banner"
      WIDTH="'.$iWidth.'"
      HEIGHT="'.$iHeight.'"
      ALIGN="">
       <PARAM NAME="movie" VALUE="'.$strImage.'" />
       <PARAM NAME="quality" VALUE="high" />
       <PARAM NAME="bgcolor" VALUE="#FFFFFF" />
       <embed
        src="'.$strImage.'"
        quality="high"
        bgcolor="#FFFFFF"
        WIDTH="'.$iWidth.'"
        HEIGHT="'.$iHeight.'"
        NAME="banner"
        ALIGN=""
        TYPE="application/x-shockwave-flash"
        PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
       </embed>
     </object>
     ';
    return $bPopup? $strReturn : print_url($strImageUrl, $strReturn);
   default:
    $strReturn = "<img src=\"".$strImage."\" ".$sParams." width=\"".$intWidth."\" height=\"".$intHeight."\" alt=\"".htmlspecialchars($strAlt)."\" />";
    if($iMaxW > 0 && $iMaxH > 0) //need to check scale, maybe show actual size in the popup window
    {
     //check for max dimensions exceeding
     if($intWidth > $iMaxW || $intHeight > $iMaxH)
     {
      $coeff = ($intWidth/$iMaxW > $intHeight/$iMaxH? $intWidth/$iMaxW : $intHeight/$iMaxH);
      $strReturn = "<img src=\"".$strImage."\" ".$sParams." width=\"".intval(roundEx($intWidth/$coeff))."\" height=\"".intval(roundEx($intHeight/$coeff))."\" alt=\"".htmlspecialchars($strAlt)."\" />";
      if($bPopup) //show in JS window
      {
       if(strlen($strImageUrl)>0)
       {
        $strReturn =
         '<a href="'.$strImageUrl.'" title="'.$sPopupTitle.'" target="_blank">'.
         '<img src="'.$strImage.'" '.$sParams.' width="'.intval(roundEx($intWidth/$coeff)).'" height="'.intval(roundEx($intHeight/$coeff)).' alt="'.htmlspecialchars($sPopupTitle).'" />'.
         '</a>';
       }
       else
       {
        CFile::OutputJSImgShw();
        $strReturn =
         "<a title=\"".$sPopupTitle."\" onClick=\"ImgShw('".AddSlashes($strImage)."','".$intWidth."','".$intHeight."', '".AddSlashes(htmlspecialcharsex(htmlspecialcharsex($strAlt)))."'); return false;\" href=\"".$strImage."\" target=\"_blank\">".
         "<img src=\"".$strImage."\" ".$sParams." width=\"".intval(roundEx($intWidth/$coeff))."\" height=\"".intval(roundEx($intHeight/$coeff))."\" /></a>";
       }
      }
     }
    }
    return $bPopup? $strReturn : print_url($strImageUrl, $strReturn);
  endswitch;
  return $bPopup? $strReturn : print_url($strImageUrl, $strReturn);
 }
?>
                                     
        
            Уникальный фрагмент кода из CMS Bitrix 7.x.
Судя по всему его писал индус который не проверял его работы.
Некотором будет непонятен тонкий юмор автора этого кода, но когда пытаешься решить с его помощью конкретную задачу становится совсем не смешно а наоборот обидно, за себя и толпы тысяч людей полагающих что Bitrix решение всех его проблем логика работы в котором напрочь отсутствует так же как и здравый смысл.
Сделаю небольшой намёк. Весь фокус во взаимной зависимости параметров
$iMaxW=0, $iMaxH=0, $strImageUrl="", $bPopup=false