With the {F...} syntax, render non-images as links

Summary:
We render a huge picture of a PDF for PDFs right now, etc. This is hella dumb.

Also allow users to force this rendering style, and change the link name.

Test Plan: Uploaded image and non-image files, used layout=link and name=....

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T1040

Differential Revision: https://secure.phabricator.com/D2006
This commit is contained in:
epriestley
2012-03-23 15:32:07 -07:00
parent 2ef3e69e58
commit 2ee5086ce9
5 changed files with 54 additions and 24 deletions

View File

@@ -277,7 +277,7 @@ celerity_register_resource_map(array(
),
'diffusion-icons-css' =>
array(
'uri' => '/res/2633e4b7/rsrc/css/application/diffusion/diffusion-icons.css',
'uri' => '/res/b7e2a749/rsrc/css/application/diffusion/diffusion-icons.css',
'type' => 'css',
'requires' =>
array(
@@ -1692,7 +1692,7 @@ celerity_register_resource_map(array(
),
'phabricator-remarkup-css' =>
array(
'uri' => '/res/3a0eb9e5/rsrc/css/core/remarkup.css',
'uri' => '/res/11f89984/rsrc/css/core/remarkup.css',
'type' => 'css',
'requires' =>
array(
@@ -1968,7 +1968,7 @@ celerity_register_resource_map(array(
), array(
'packages' =>
array(
'05e42357' =>
'66f447f1' =>
array(
'name' => 'core.pkg.css',
'symbols' =>
@@ -1993,7 +1993,7 @@ celerity_register_resource_map(array(
17 => 'aphront-pager-view-css',
18 => 'phabricator-transaction-view-css',
),
'uri' => '/res/pkg/05e42357/core.pkg.css',
'uri' => '/res/pkg/66f447f1/core.pkg.css',
'type' => 'css',
),
'21d01ed8' =>
@@ -2140,17 +2140,17 @@ celerity_register_resource_map(array(
'reverse' =>
array(
'aphront-attached-file-view-css' => '31583232',
'aphront-crumbs-view-css' => '05e42357',
'aphront-dialog-view-css' => '05e42357',
'aphront-form-view-css' => '05e42357',
'aphront-crumbs-view-css' => '66f447f1',
'aphront-dialog-view-css' => '66f447f1',
'aphront-form-view-css' => '66f447f1',
'aphront-headsup-action-list-view-css' => '551249fc',
'aphront-list-filter-view-css' => '05e42357',
'aphront-pager-view-css' => '05e42357',
'aphront-panel-view-css' => '05e42357',
'aphront-side-nav-view-css' => '05e42357',
'aphront-table-view-css' => '05e42357',
'aphront-tokenizer-control-css' => '05e42357',
'aphront-typeahead-control-css' => '05e42357',
'aphront-list-filter-view-css' => '66f447f1',
'aphront-pager-view-css' => '66f447f1',
'aphront-panel-view-css' => '66f447f1',
'aphront-side-nav-view-css' => '66f447f1',
'aphront-table-view-css' => '66f447f1',
'aphront-tokenizer-control-css' => '66f447f1',
'aphront-typeahead-control-css' => '66f447f1',
'differential-changeset-view-css' => '551249fc',
'differential-core-view-css' => '551249fc',
'differential-inline-comment-editor' => '9b256876',
@@ -2208,23 +2208,23 @@ celerity_register_resource_map(array(
'maniphest-task-detail-css' => '31583232',
'maniphest-task-summary-css' => '31583232',
'maniphest-transaction-detail-css' => '31583232',
'phabricator-app-buttons-css' => '05e42357',
'phabricator-app-buttons-css' => '66f447f1',
'phabricator-content-source-view-css' => '551249fc',
'phabricator-core-buttons-css' => '05e42357',
'phabricator-core-css' => '05e42357',
'phabricator-directory-css' => '05e42357',
'phabricator-core-buttons-css' => '66f447f1',
'phabricator-core-css' => '66f447f1',
'phabricator-directory-css' => '66f447f1',
'phabricator-drag-and-drop-file-upload' => '9b256876',
'phabricator-dropdown-menu' => '21d01ed8',
'phabricator-jump-nav' => '05e42357',
'phabricator-jump-nav' => '66f447f1',
'phabricator-keyboard-shortcut' => '21d01ed8',
'phabricator-keyboard-shortcut-manager' => '21d01ed8',
'phabricator-menu-item' => '21d01ed8',
'phabricator-object-selector-css' => '551249fc',
'phabricator-paste-file-upload' => '21d01ed8',
'phabricator-remarkup-css' => '05e42357',
'phabricator-remarkup-css' => '66f447f1',
'phabricator-shaped-request' => '9b256876',
'phabricator-standard-page-view' => '05e42357',
'phabricator-transaction-view-css' => '05e42357',
'syntax-highlighting-css' => '05e42357',
'phabricator-standard-page-view' => '66f447f1',
'phabricator-transaction-view-css' => '66f447f1',
'syntax-highlighting-css' => '66f447f1',
),
));

View File

@@ -296,10 +296,13 @@ You can set file display options like this:
Valid options are:
- **layout** left (default), center, right, inline
- **layout** left (default), center, right, inline, link (render a link
instead of a thumbnail for images)
- **float** If layout is set to left or right, the image will be floated so
text wraps around it.
- **size** thumb (default), full
- **name** with `layout=link` or for non-images, use this name for the link
text
= Embedding Media =

View File

@@ -45,6 +45,7 @@ final class PhabricatorRemarkupRuleEmbedFile
'size' => 'thumb',
'layout' => 'left',
'float' => false,
'name' => null,
);
if (!empty($matches[2])) {
@@ -52,6 +53,21 @@ final class PhabricatorRemarkupRuleEmbedFile
$options = PhutilSimpleOptions::parse($matches[2]) + $options;
}
$file_name = coalesce($options['name'], $file->getName());
if (!$file->isViewableImage() || $options['layout'] == 'link') {
// If a file isn't in image, just render a link to it.
$link = phutil_render_tag(
'a',
array(
'href' => $file->getBestURI(),
'target' => '_blank',
'class' => 'phabricator-remarkup-embed-layout-link',
),
phutil_escape_html($file_name));
return $this->getEngine()->storeText($link);
}
switch ($options['size']) {
case 'full':
$src_uri = $file->getBestURI();

View File

@@ -204,6 +204,11 @@
margin: .5em 1em 0;
}
.phabricator-remarkup-embed-layout-link {
padding-left: 20px;
background: url(/rsrc/image/icon/fatcow/page_white_put.png) 0 0 no-repeat;
}
.phabricator-remarkup-embed-float-left {
float: left;
margin: .5em 1em 0;
@@ -211,4 +216,10 @@
img.phabricator-remarkup-embed-image {
display: inline;
border: 2px solid white;
background: white;
box-shadow: 1px 1px 6px rgba(0,0,0,.5);
-moz-box-shadow: 1px 1px 6px rgba(0,0,0,.5);
-webkit-box-shadow: 1px 1px 6px rgba(0,0,0,.5);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B