@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+46 -15
+44 -15
src/applications/files/remarkup/PhabricatorRemarkupRuleEmbedFile.php
··· 50 50 51 51 private function getFileOptions($option_string) { 52 52 $options = array( 53 - 'size' => 'thumb', 53 + 'size' => null, 54 54 'layout' => 'left', 55 55 'float' => false, 56 + 'width' => null, 57 + 'height' => null, 56 58 ); 57 59 58 60 if ($option_string) { ··· 73 75 74 76 $attrs = array(); 75 77 $image_class = null; 76 - switch ((string)$options['size']) { 77 - case 'full': 78 + 79 + $use_size = true; 80 + if (!$options['size']) { 81 + $width = $this->parseDimension($options['width']); 82 + $height = $this->parseDimension($options['height']); 83 + if ($width || $height) { 84 + $use_size = false; 78 85 $attrs += array( 79 86 'src' => $file->getBestURI(), 80 - 'width' => $file->getImageWidth(), 81 - 'height' => $file->getImageHeight(), 87 + 'width' => $width, 88 + 'height' => $height, 82 89 ); 83 - break; 84 - case 'thumb': 85 - default: 86 - $attrs['src'] = $file->getPreview220URI(); 87 - $dimensions = 88 - PhabricatorImageTransformer::getPreviewDimensions($file, 220); 89 - $attrs['width'] = $dimensions['sdx']; 90 - $attrs['height'] = $dimensions['sdy']; 91 - $image_class = 'phabricator-remarkup-embed-image'; 92 - break; 90 + } 91 + } 92 + 93 + if ($use_size) { 94 + switch ((string)$options['size']) { 95 + case 'full': 96 + $attrs += array( 97 + 'src' => $file->getBestURI(), 98 + 'width' => $file->getImageWidth(), 99 + 'height' => $file->getImageHeight(), 100 + ); 101 + break; 102 + case 'thumb': 103 + default: 104 + $attrs['src'] = $file->getPreview220URI(); 105 + $dimensions = 106 + PhabricatorImageTransformer::getPreviewDimensions($file, 220); 107 + $attrs['width'] = $dimensions['sdx']; 108 + $attrs['height'] = $dimensions['sdy']; 109 + $image_class = 'phabricator-remarkup-embed-image'; 110 + break; 111 + } 93 112 } 94 113 95 114 $img = phutil_tag('img', $attrs); ··· 184 203 ->setFileDownloadURI($file->getDownloadURI()) 185 204 ->setFileViewURI($file->getBestURI()) 186 205 ->setFileViewable($options['viewable']); 206 + } 207 + 208 + private function parseDimension($string) { 209 + $string = trim($string); 210 + 211 + if (preg_match('/^(?:\d*\\.)?\d+%?$/', $string)) { 212 + return $string; 213 + } 214 + 215 + return null; 187 216 } 188 217 189 218 }
+2
src/docs/user/userguide/remarkup.diviner
··· 345 345 - **size** thumb (default), full 346 346 - **name** with `layout=link` or for non-images, use this name for the link 347 347 text 348 + - **width** Scale image to a specific width. 349 + - **height** Scale image to a specific height. 348 350 349 351 == Embedding Countdowns 350 352