Example #1
0
 private static function makeImageBlock(Post $post, $display)
 {
     /**
      * The following block is only for posts with an image attached.
      */
     if ($post->hasImage() && !$post->imgbanned) {
         $md5Filename = str_replace('/', '-', $post->md5);
         $humanFilesize = $post->fsize > 0 ? human_filesize($post->fsize) . ", " : "";
         list($thumbW, $thumbH) = tn_Size($post->w, $post->h);
         if ($display == self::DISPLAY_OP && ($post->w > 125 || $post->h > 125)) {
             //OP thumbs are 250x250 rather than 125x125
             $thumbW *= 2;
             $thumbH *= 2;
         }
         $thumb = "<a class='fileThumb' href='{$post->getImgUrl()}' target='_blank'>" . "<img src='{$post->getThumbUrl()}' alt='' data-md5='{$post->md5}' data-md5-filename='{$md5Filename}' data-ext='{$post->ext}' data-full-img='{$post->getImgUrl()}' width='{$thumbW}' height='{$thumbH}' data-width='{$post->w}' data-height='{$post->h}' />" . "</a>";
         $chanMedia = $post->board == 'f' ? '//i.4cdn.org/f/src/' . $post->filename . $post->ext : '//i.4cdn.org/' . $post->board . '/src/' . $post->tim . $post->ext;
         $fullImgLink = $post->getExtension() == '.swf' ? $post->getSwfUrl() : $post->getImgUrl();
         $fileDiv = div('', 'file')->set('id', 'f' . $post->no);
         $fileInfo = div('', 'fileInfo');
         $fileText = span('', 'fileText')->set('id', 'fT' . $post->no)->set('data-filename', $post->filename . $post->ext);
         $fileText->append(a($post->filename . $post->ext, $chanMedia)->set("target", "_blank")->set("title", $post->filename . $post->ext)->set("class", 'imageLink')->set('rel', 'noreferrer'))->append('&nbsp;')->append("({$humanFilesize}{$post->w}x{$post->h}, " . ($post->board == 'f' ? $post->tag . ")" : "<span title='{$post->filename}{$post->ext}'>{$post->tim}{$post->ext}</span>)&nbsp;"));
         if ($post->getExtension() != '.swf') {
             $fileText->append(a('iqdb', "http://iqdb.org/?url={$post->getThumbUrl()}")->set("target", "_blank") . '&nbsp;' . a('google', "http://www.google.com/searchbyimage?image_url={$post->getThumbUrl()}")->set("target", "_blank"));
         }
         $fileText->append('&nbsp;' . a('reposts', "/{$post->board}/search/md5/{$post->getMD5Hex()}")->set("target", "_blank") . '&nbsp;' . a('full', $fullImgLink)->set("target", '_blank'));
         $fileInfo->append($fileText);
         $fileDiv->append($fileInfo);
         $fileDiv->append($thumb);
         return $fileDiv;
     } else {
         if ($post->imgbanned) {
             return Site::parseHtmlFragment("post/banned_image.html");
         } else {
             return "";
         }
     }
 }