Exemple #1
0
 /**
  * Creates image link
  *
  * @param   Image_Model|int  $image  or image_id
  * @param   string           $size   thumb|normal
  * @param   string|array     $alt    alt attribute or array of attributes
  * @return  string
  */
 public static function img($image = null, $size = 'normal', $alt = null)
 {
     if (!$image instanceof Image_Model) {
         $image = new Image_Model((int) $image);
     }
     switch ($size) {
         case 'original':
             $size_prefix = 'original_';
             break;
         case 'normal':
             $size_prefix = '';
             break;
         case 'thumb':
             $size_prefix = 'thumb_';
             break;
     }
     $attributes = is_array($alt) ? $alt : array('width' => $image->{$size_prefix . 'width'}, 'height' => $image->{$size_prefix . 'height'}, 'alt' => is_string($alt) ? $alt : ($size == 'thumb' ? __('Thumb') : __('Image')) . ' ' . sprintf('[%dx%d]', $image->{$size_prefix . 'width'}, $image->{$size_prefix . 'height'}));
     return html::image($image->url($size), $attributes);
 }