mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 20:40:56 +01:00
Add explicit width/height controls for embedded images in Remarkup
Summary: User request. See screenshot. Test Plan: doge Reviewers: btrahan, bigo Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D7610
This commit is contained in:
parent
ccfce7c4ee
commit
ab64ad1257
2 changed files with 46 additions and 15 deletions
|
@ -50,9 +50,11 @@ final class PhabricatorRemarkupRuleEmbedFile
|
||||||
|
|
||||||
private function getFileOptions($option_string) {
|
private function getFileOptions($option_string) {
|
||||||
$options = array(
|
$options = array(
|
||||||
'size' => 'thumb',
|
'size' => null,
|
||||||
'layout' => 'left',
|
'layout' => 'left',
|
||||||
'float' => false,
|
'float' => false,
|
||||||
|
'width' => null,
|
||||||
|
'height' => null,
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($option_string) {
|
if ($option_string) {
|
||||||
|
@ -73,6 +75,22 @@ final class PhabricatorRemarkupRuleEmbedFile
|
||||||
|
|
||||||
$attrs = array();
|
$attrs = array();
|
||||||
$image_class = null;
|
$image_class = null;
|
||||||
|
|
||||||
|
$use_size = true;
|
||||||
|
if (!$options['size']) {
|
||||||
|
$width = $this->parseDimension($options['width']);
|
||||||
|
$height = $this->parseDimension($options['height']);
|
||||||
|
if ($width || $height) {
|
||||||
|
$use_size = false;
|
||||||
|
$attrs += array(
|
||||||
|
'src' => $file->getBestURI(),
|
||||||
|
'width' => $width,
|
||||||
|
'height' => $height,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($use_size) {
|
||||||
switch ((string)$options['size']) {
|
switch ((string)$options['size']) {
|
||||||
case 'full':
|
case 'full':
|
||||||
$attrs += array(
|
$attrs += array(
|
||||||
|
@ -91,6 +109,7 @@ final class PhabricatorRemarkupRuleEmbedFile
|
||||||
$image_class = 'phabricator-remarkup-embed-image';
|
$image_class = 'phabricator-remarkup-embed-image';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$img = phutil_tag('img', $attrs);
|
$img = phutil_tag('img', $attrs);
|
||||||
|
|
||||||
|
@ -186,4 +205,14 @@ final class PhabricatorRemarkupRuleEmbedFile
|
||||||
->setFileViewable($options['viewable']);
|
->setFileViewable($options['viewable']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function parseDimension($string) {
|
||||||
|
$string = trim($string);
|
||||||
|
|
||||||
|
if (preg_match('/^(?:\d*\\.)?\d+%?$/', $string)) {
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -345,6 +345,8 @@ Valid options are:
|
||||||
- **size** thumb (default), full
|
- **size** thumb (default), full
|
||||||
- **name** with `layout=link` or for non-images, use this name for the link
|
- **name** with `layout=link` or for non-images, use this name for the link
|
||||||
text
|
text
|
||||||
|
- **width** Scale image to a specific width.
|
||||||
|
- **height** Scale image to a specific height.
|
||||||
|
|
||||||
== Embedding Countdowns
|
== Embedding Countdowns
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue