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)); }
private function renderImageFile(PhabricatorFile $file, PhabricatorObjectHandle $handle, array $options) { require_celerity_resource('lightbox-attachment-css'); $attrs = array(); $image_class = null; $use_size = true; if (!$options['size']) { $width = $this->parseDimension($options['width']); $height = $this->parseDimension($options['height']); if ($width || $height) { $use_size = false; $attrs += array('src' => $file->getBestURI(), 'width' => $width, 'height' => $height); } } if ($use_size) { switch ((string) $options['size']) { case 'full': $attrs += array('src' => $file->getBestURI()); $image_class = 'phabricator-remarkup-embed-image-full'; break; case 'thumb': default: $attrs['src'] = $file->getPreview220URI(); $dimensions = PhabricatorImageTransformer::getPreviewDimensions($file, 220); $attrs['width'] = $dimensions['sdx']; $attrs['height'] = $dimensions['sdy']; $image_class = 'phabricator-remarkup-embed-image'; break; } } if (isset($options['alt'])) { $attrs['alt'] = $options['alt']; } $img = phutil_tag('img', $attrs); $embed = javelin_tag('a', array('href' => $file->getBestURI(), 'class' => $image_class, 'sigil' => 'lightboxable', 'meta' => array('phid' => $file->getPHID(), 'uri' => $file->getBestURI(), 'dUri' => $file->getDownloadURI(), 'viewable' => true)), $img); switch ($options['layout']) { case 'right': case 'center': case 'inline': case 'left': $layout_class = 'phabricator-remarkup-embed-layout-' . $options['layout']; break; default: $layout_class = 'phabricator-remarkup-embed-layout-left'; break; } if ($options['float']) { switch ($options['layout']) { case 'center': case 'inline': break; case 'right': $layout_class .= ' phabricator-remarkup-embed-float-right'; break; case 'left': default: $layout_class .= ' phabricator-remarkup-embed-float-left'; break; } } return phutil_tag('div', array('class' => $layout_class), $embed); }