mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 02:32:42 +01:00
Don't do image stuff with unviewable images
Summary: If a file isn't a viewable image, don't try to figure out metadata (size, etc.) when rendering a `{F...}` tag in Remarkup. Test Plan: Uploaded a .rtf, added it as `{F1}` in a new Maniphest task, saw no errors in the dark console. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2479 Differential Revision: https://secure.phabricator.com/D4837
This commit is contained in:
parent
361ce491f2
commit
fb7d5d17a2
1 changed files with 28 additions and 24 deletions
|
@ -50,7 +50,10 @@ final class PhabricatorRemarkupRuleEmbedFile
|
||||||
$file_name = coalesce($options['name'], $file->getName());
|
$file_name = coalesce($options['name'], $file->getName());
|
||||||
$options['name'] = $file_name;
|
$options['name'] = $file_name;
|
||||||
|
|
||||||
|
$is_viewable_image = $file->isViewableImage();
|
||||||
|
|
||||||
$attrs = array();
|
$attrs = array();
|
||||||
|
if ($is_viewable_image) {
|
||||||
switch ((string)$options['size']) {
|
switch ((string)$options['size']) {
|
||||||
case 'full':
|
case 'full':
|
||||||
$attrs['src'] = $file->getBestURI();
|
$attrs['src'] = $file->getBestURI();
|
||||||
|
@ -75,12 +78,13 @@ final class PhabricatorRemarkupRuleEmbedFile
|
||||||
$options['image_class'] = 'phabricator-remarkup-embed-image';
|
$options['image_class'] = 'phabricator-remarkup-embed-image';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$bundle['attrs'] = $attrs;
|
$bundle['attrs'] = $attrs;
|
||||||
$bundle['options'] = $options;
|
$bundle['options'] = $options;
|
||||||
|
|
||||||
$bundle['meta'] = array(
|
$bundle['meta'] = array(
|
||||||
'phid' => $file->getPHID(),
|
'phid' => $file->getPHID(),
|
||||||
'viewable' => $file->isViewableImage(),
|
'viewable' => $is_viewable_image,
|
||||||
'uri' => $file->getBestURI(),
|
'uri' => $file->getBestURI(),
|
||||||
'dUri' => $file->getDownloadURI(),
|
'dUri' => $file->getDownloadURI(),
|
||||||
'name' => $options['name'],
|
'name' => $options['name'],
|
||||||
|
|
Loading…
Reference in a new issue