예제 #1
0
 public function parseImage($text)
 {
     preg_match_all("#\\[img:{$this->uid}\\](?<url>[^[]+)\\[/img:{$this->uid}\\]#", $text, $images, PREG_SET_ORDER);
     $index = 0;
     foreach ($images as $i) {
         $proxiedSrc = proxy_image($i['url']);
         $imageTag = '';
         $imageSize = fast_imagesize($proxiedSrc);
         if ($imageSize !== false && $imageSize[0] !== 0) {
             $heightPercentage = $imageSize[1] / $imageSize[0] * 100;
             $topClass = 'proportional-container';
             if ($this->withGallery) {
                 $topClass .= ' js-gallery';
             }
             $imageTag .= "<span class='{$topClass}' style='width: {$imageSize[0]}px;' data-width='{$imageSize[0]}' data-height='{$imageSize[1]}' data-index='{$index}' data-gallery-id='{$this->refId}' data-src='{$proxiedSrc}'>";
             $imageTag .= "<span class='proportional-container__height' style='padding-bottom: {$heightPercentage}%;'>";
             $imageTag .= lazy_load_image($proxiedSrc, 'proportional-container__content');
             $imageTag .= '</span>';
             $imageTag .= '</span>';
             $index += 1;
         } else {
             $imageTag .= lazy_load_image($proxiedSrc);
         }
         $text = str_replace($i[0], $imageTag, $text);
     }
     return $text;
 }
예제 #2
0
 public function parseImage($text)
 {
     preg_match_all("#\\[img:{$this->uid}\\](?<url>[^[]+)\\[/img:{$this->uid}\\]#", $text, $images, PREG_SET_ORDER);
     foreach ($images as $i) {
         $proxiedSrc = proxy_image($i["url"]);
         $text = str_replace($i[0], lazy_load_image($proxiedSrc), $text);
     }
     return $text;
 }