diff --git a/src/applications/macro/controller/PhabricatorMacroMemeController.php b/src/applications/macro/controller/PhabricatorMacroMemeController.php --- a/src/applications/macro/controller/PhabricatorMacroMemeController.php +++ b/src/applications/macro/controller/PhabricatorMacroMemeController.php @@ -49,7 +49,9 @@ ->withPHIDs(array($xform->getTransformedPHID())) ->executeOne(); if ($memefile) { - return $memefile->getBestURI(); + $preview_key = PhabricatorFileThumbnailTransform::TRANSFORM_PREVIEW; + $xform = PhabricatorFileTransform::getTransformByKey($preview_key); + return $memefile->getURIForTransform($xform); } } @@ -63,6 +65,8 @@ $xfile->setTransform($hash); $xfile->save(); - return $newfile->getBestURI(); + $preview_key = PhabricatorFileThumbnailTransform::TRANSFORM_PREVIEW; + $xform = PhabricatorFileTransform::getTransformByKey($preview_key); + return $newfile->getURIForTransform($xform); } } diff --git a/src/applications/macro/markup/PhabricatorImageMacroRemarkupRule.php b/src/applications/macro/markup/PhabricatorImageMacroRemarkupRule.php --- a/src/applications/macro/markup/PhabricatorImageMacroRemarkupRule.php +++ b/src/applications/macro/markup/PhabricatorImageMacroRemarkupRule.php @@ -136,15 +136,35 @@ )); } + $dimensions_width = $file->getImageWidth(); + $dimensions_height = $file->getImageHeight(); + if ($file->getMimeType() !== 'image/gif') { + $preview_key = PhabricatorFileThumbnailTransform::TRANSFORM_PREVIEW; + $xform = PhabricatorFileTransform::getTransformByKey($preview_key); + + $dimensions = $xform->getTransformedDimensions($file); + if ($dimensions) { + list($x, $y) = $dimensions; + $dimensions_width = $x; + $dimensions_height = $y; + } + + $uri = $file->getURIForTransform($xform); + } else { + $uri = $file->getBestURI(); + } + + $image_class = 'phabricator-remarkup-embed-image'; + $result = $this->newTag( 'img', array( 'id' => $id, - 'src' => $src_uri, + 'src' => $uri, 'alt' => $spec['original'], 'title' => $spec['original'], - 'height' => $file->getImageHeight(), - 'width' => $file->getImageWidth(), + 'height' => $dimensions_height, + 'width' => $dimensions_width, 'class' => 'phabricator-remarkup-macro', ));