Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php
| Show All 10 Lines | final class PhabricatorEmbedFileRemarkupRule | ||||
| protected function loadObjects(array $ids) { | protected function loadObjects(array $ids) { | ||||
| $engine = $this->getEngine(); | $engine = $this->getEngine(); | ||||
| $viewer = $engine->getConfig('viewer'); | $viewer = $engine->getConfig('viewer'); | ||||
| $objects = id(new PhabricatorFileQuery()) | $objects = id(new PhabricatorFileQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withIDs($ids) | ->withIDs($ids) | ||||
| ->needTransforms( | |||||
| array( | |||||
| PhabricatorFileThumbnailTransform::TRANSFORM_PREVIEW, | |||||
| )) | |||||
| ->execute(); | ->execute(); | ||||
| $phids_key = self::KEY_EMBED_FILE_PHIDS; | $phids_key = self::KEY_EMBED_FILE_PHIDS; | ||||
| $phids = $engine->getTextMetadata($phids_key, array()); | $phids = $engine->getTextMetadata($phids_key, array()); | ||||
| foreach (mpull($objects, 'getPHID') as $phid) { | foreach (mpull($objects, 'getPHID') as $phid) { | ||||
| $phids[] = $phid; | $phids[] = $phid; | ||||
| } | } | ||||
| $engine->setTextMetadata($phids_key, $phids); | $engine->setTextMetadata($phids_key, $phids); | ||||
| ▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | if ($use_size) { | ||||
| 'width' => $file->getImageWidth(), | 'width' => $file->getImageWidth(), | ||||
| ); | ); | ||||
| $image_class = 'phabricator-remarkup-embed-image-full'; | $image_class = 'phabricator-remarkup-embed-image-full'; | ||||
| break; | break; | ||||
| case 'thumb': | case 'thumb': | ||||
| default: | default: | ||||
| $preview_key = PhabricatorFileThumbnailTransform::TRANSFORM_PREVIEW; | $preview_key = PhabricatorFileThumbnailTransform::TRANSFORM_PREVIEW; | ||||
| $xform = PhabricatorFileTransform::getTransformByKey($preview_key); | $xform = PhabricatorFileTransform::getTransformByKey($preview_key); | ||||
| $attrs['src'] = $file->getURIForTransform($xform); | |||||
| $existing_xform = $file->getTransform($preview_key); | |||||
| if ($existing_xform) { | |||||
| $xform_uri = $existing_xform->getCDNURI(); | |||||
| } else { | |||||
| $xform_uri = $file->getURIForTransform($xform); | |||||
| } | |||||
| $attrs['src'] = $xform_uri; | |||||
| $dimensions = $xform->getTransformedDimensions($file); | $dimensions = $xform->getTransformedDimensions($file); | ||||
| if ($dimensions) { | if ($dimensions) { | ||||
| list($x, $y) = $dimensions; | list($x, $y) = $dimensions; | ||||
| $attrs['width'] = $x; | $attrs['width'] = $x; | ||||
| $attrs['height'] = $y; | $attrs['height'] = $y; | ||||
| } | } | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines | |||||