diff --git a/src/applications/pholio/remarkup/PholioRemarkupRule.php b/src/applications/pholio/remarkup/PholioRemarkupRule.php index 4545a23a87..998c47a55a 100644 --- a/src/applications/pholio/remarkup/PholioRemarkupRule.php +++ b/src/applications/pholio/remarkup/PholioRemarkupRule.php @@ -1,8 +1,5 @@ getURI(); + + // If the ID has a `M123/456` component, link to that specific image. + $id = explode('/', $id); + if (isset($id[1])) { + $href = $href.'/'.$id[1].'/'; + } + + return $href; + } + protected function loadObjects(array $ids) { + // Strip off any image ID components of the URI. + $map = array(); + foreach ($ids as $id) { + $map[head(explode('/', $id))][] = $id; + } + $viewer = $this->getEngine()->getConfig('viewer'); - return id(new PholioMockQuery()) + $mocks = id(new PholioMockQuery()) ->setViewer($viewer) ->needCoverFiles(true) ->needImages(true) ->needTokenCounts(true) - ->withIDs($ids) + ->withIDs(array_keys($map)) ->execute(); + + $results = array(); + foreach ($mocks as $mock) { + $ids = idx($map, $mock->getID(), array()); + foreach ($ids as $id) { + $results[$id] = $mock; + } + } + + return $results; } protected function renderObjectEmbed($object, $handle, $options) { diff --git a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObject.php b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObject.php index 55fd35935c..f49a1d583d 100644 --- a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObject.php +++ b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObject.php @@ -40,8 +40,12 @@ abstract class PhabricatorRemarkupRuleObject return $result; } + protected function getObjectHref($object, $handle, $id) { + return $handle->getURI(); + } + protected function renderObjectRef($object, $handle, $anchor, $id) { - $href = $handle->getURI(); + $href = $this->getObjectHref($object, $handle, $id); $text = $this->getObjectNamePrefix().$id; if ($anchor) {