Ejemplo n.º 1
0
 private function renderThumbnail(PholioImage $image)
 {
     $thumbfile = $image->getFile();
     $preview_key = PhabricatorFileThumbnailTransform::TRANSFORM_THUMBGRID;
     $xform = PhabricatorFileTransform::getTransformByKey($preview_key);
     $attributes = array('class' => 'pholio-mock-thumb-grid-image', 'src' => $thumbfile->getURIForTransform($xform));
     if ($image->getFile()->isViewableImage()) {
         $dimensions = $xform->getTransformedDimensions($thumbfile);
         if ($dimensions) {
             list($x, $y) = $dimensions;
             $attributes += array('width' => $x, 'height' => $y, 'style' => 'top: ' . floor((100 - $y) / 2) . 'px');
         }
     } else {
         // If this is a PDF or a text file or something, we'll end up using a
         // generic thumbnail which is always sized correctly.
         $attributes += array('width' => 100, 'height' => 100);
     }
     $tag = phutil_tag('img', $attributes);
     $classes = array('pholio-mock-thumb-grid-item');
     if ($image->getIsObsolete()) {
         $classes[] = 'pholio-mock-thumb-grid-item-obsolete';
     }
     $inline_count = null;
     if ($image->getInlineComments()) {
         $inline_count[] = phutil_tag('span', array('class' => 'pholio-mock-thumb-grid-comment-count'), pht('%s', new PhutilNumber(count($image->getInlineComments()))));
     }
     return javelin_tag('a', array('sigil' => 'mock-thumbnail', 'class' => implode(' ', $classes), 'href' => '#', 'meta' => array('imageID' => $image->getID())), array($tag, $inline_count));
 }
Ejemplo n.º 2
0
 private function renderThumbnail(PholioImage $image)
 {
     $thumbfile = $image->getFile();
     if ($image->getFile()->isViewableImage()) {
         $dimensions = PhabricatorImageTransformer::getPreviewDimensions($thumbfile, 100);
     } else {
         // If this is a PDF or a text file or something, we'll end up using a
         // generic thumbnail which is always sized correctly.
         $dimensions = array('sdx' => 100, 'sdy' => 100);
     }
     $tag = phutil_tag('img', array('width' => $dimensions['sdx'], 'height' => $dimensions['sdy'], 'src' => $thumbfile->getPreview100URI(), 'class' => 'pholio-mock-thumb-grid-image', 'style' => 'top: ' . floor((100 - $dimensions['sdy']) / 2) . 'px'));
     $classes = array('pholio-mock-thumb-grid-item');
     if ($image->getIsObsolete()) {
         $classes[] = 'pholio-mock-thumb-grid-item-obsolete';
     }
     $inline_count = null;
     if ($image->getInlineComments()) {
         $inline_count[] = phutil_tag('span', array('class' => 'pholio-mock-thumb-grid-comment-count'), pht('%s', new PhutilNumber(count($image->getInlineComments()))));
     }
     return javelin_tag('a', array('sigil' => 'mock-thumbnail', 'class' => implode(' ', $classes), 'href' => '#', 'meta' => array('imageID' => $image->getID())), array($tag, $inline_count));
 }