Remarkup - add as much image dimension hinting as possible
Summary: this was done for conpherence so the auto-scroll actually works. NOTE we actually use the 220 preview UI for file attachments right now so this really only helps in the macro case. :/ Test Plan: sent some conpherences with macros and files. verified image width / height was set as expected. Reviewers: epriestley, chad Reviewed By: chad CC: aran, Korvin Maniphest Tasks: T2399 Differential Revision: https://secure.phabricator.com/D4678
This commit is contained in:
parent
22ce74c5a8
commit
ad29c98610
|
@ -55,10 +55,20 @@ final class PhabricatorRemarkupRuleEmbedFile
|
||||||
case 'full':
|
case 'full':
|
||||||
$attrs['src'] = $file->getBestURI();
|
$attrs['src'] = $file->getBestURI();
|
||||||
$options['image_class'] = null;
|
$options['image_class'] = null;
|
||||||
|
$file_data = $file->getMetadata();
|
||||||
|
$height = $file_data[PhabricatorFile::METADATA_IMAGE_HEIGHT];
|
||||||
|
if ($height) {
|
||||||
|
$attrs['height'] = $height;
|
||||||
|
}
|
||||||
|
$width = $file_data[PhabricatorFile::METADATA_IMAGE_WIDTH];
|
||||||
|
if ($width) {
|
||||||
|
$attrs['width'] = $width;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'thumb':
|
case 'thumb':
|
||||||
default:
|
default:
|
||||||
$attrs['src'] = $file->getPreview220URI();
|
$attrs['src'] = $file->getPreview220URI();
|
||||||
|
$attrs['width'] = '220';
|
||||||
$options['image_class'] = 'phabricator-remarkup-embed-image';
|
$options['image_class'] = 'phabricator-remarkup-embed-image';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,20 @@ final class PhabricatorRemarkupRuleImageMacro
|
||||||
$phid = $this->images[$matches[1]];
|
$phid = $this->images[$matches[1]];
|
||||||
|
|
||||||
$file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $phid);
|
$file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $phid);
|
||||||
|
$style = null;
|
||||||
|
$src_uri = null;
|
||||||
if ($file) {
|
if ($file) {
|
||||||
$src_uri = $file->getBestURI();
|
$src_uri = $file->getBestURI();
|
||||||
} else {
|
$file_data = $file->getMetadata();
|
||||||
$src_uri = null;
|
$height = $file_data[PhabricatorFile::METADATA_IMAGE_HEIGHT];
|
||||||
|
$width = $file_data[PhabricatorFile::METADATA_IMAGE_WIDTH];
|
||||||
|
if ($height && $width) {
|
||||||
|
$style = sprintf(
|
||||||
|
'height: %dpx; width: %dpx;',
|
||||||
|
$height,
|
||||||
|
$width
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$img = phutil_render_tag(
|
$img = phutil_render_tag(
|
||||||
|
@ -40,7 +50,8 @@ final class PhabricatorRemarkupRuleImageMacro
|
||||||
array(
|
array(
|
||||||
'src' => $src_uri,
|
'src' => $src_uri,
|
||||||
'alt' => $matches[1],
|
'alt' => $matches[1],
|
||||||
'title' => $matches[1]),
|
'title' => $matches[1],
|
||||||
|
'style' => $style),
|
||||||
null);
|
null);
|
||||||
return $this->getEngine()->storeText($img);
|
return $this->getEngine()->storeText($img);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue