Пример #1
0
 public static function getEmbedImgHtml($photo, $size, $attributes = array(), $style = true)
 {
     if ($photo['width'] && $photo['height']) {
         $real_sizes = photosPhoto::getRealSizesOfThumb($photo, $size);
         if ($real_sizes && $real_sizes['width'] && $real_sizes['height'] && $style) {
             $attributes['style'] = !empty($attributes['style']) ? $attributes['style'] : '';
             $attributes['style'] .= 'width: ' . (int) $real_sizes['width'] . 'px; height: ' . (int) $real_sizes['height'] . 'px; ';
             $attributes['width'] = (int) $real_sizes['width'];
             $attributes['height'] = (int) $real_sizes['height'];
         }
     }
     if (!isset($attributes['alt'])) {
         $attributes['alt'] = '';
     }
     $photo['src'] = photosPhoto::getPhotoUrl($photo, $size, true);
     if ($photo['edit_datetime']) {
         $photo['src'] .= '?' . strtotime($photo['edit_datetime']);
     }
     $attr = '';
     foreach ($attributes as $name => $value) {
         if (preg_match('/^%(.+)%$/', $value, $matches) && isset($photo[$matches[1]])) {
             $value = $photo[$matches[1]];
         }
         $value = htmlentities($value, ENT_QUOTES, 'utf-8');
         $attr .= $name . '="' . $value . '" ';
     }
     return "<img src=\"{$photo['src']}\" {$attr}>";
     // use everywhere only one type of quotes
 }