1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

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:
Bob Trahan 2013-01-26 18:59:35 -08:00
parent 22ce74c5a8
commit ad29c98610
2 changed files with 24 additions and 3 deletions

View file

@ -55,10 +55,20 @@ final class PhabricatorRemarkupRuleEmbedFile
case 'full':
$attrs['src'] = $file->getBestURI();
$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;
case 'thumb':
default:
$attrs['src'] = $file->getPreview220URI();
$attrs['width'] = '220';
$options['image_class'] = 'phabricator-remarkup-embed-image';
break;
}

View file

@ -29,10 +29,20 @@ final class PhabricatorRemarkupRuleImageMacro
$phid = $this->images[$matches[1]];
$file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $phid);
$style = null;
$src_uri = null;
if ($file) {
$src_uri = $file->getBestURI();
} else {
$src_uri = null;
$file_data = $file->getMetadata();
$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(
@ -40,7 +50,8 @@ final class PhabricatorRemarkupRuleImageMacro
array(
'src' => $src_uri,
'alt' => $matches[1],
'title' => $matches[1]),
'title' => $matches[1],
'style' => $style),
null);
return $this->getEngine()->storeText($img);
} else {