From bfe73f585fb02d9671ea2b8471b51ff2446da2ac Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 31 May 2011 19:42:28 -0700 Subject: [PATCH] Crop screenshot thumbs in Maniphest Summary: If you name an attached file something like "derpderpderpderpderdperdperpereprederpderplolololololo.png", the display overflows. Crop and shorten it so that it looks decent. Show the full name as the image title. Test Plan: Named a file "derpderpderpderpderdperdperpereprederpderplolololololo.png" and got a sensible display out of it. Reviewed By: tuomaspelkonen Reviewers: tuomaspelkonen, jungejason, aran CC: aran, tuomaspelkonen Differential Revision: 389 --- src/__celerity_resource_map__.php | 2 +- .../filepreview/AphrontFilePreviewView.php | 16 +++++++++++++++- webroot/rsrc/css/aphront/attached-file-view.css | 4 ++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 59b7cfc291..3a7830ad08 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -9,7 +9,7 @@ celerity_register_resource_map(array( 'aphront-attached-file-view-css' => array( - 'uri' => '/res/bac9f95c/rsrc/css/aphront/attached-file-view.css', + 'uri' => '/res/a6ca5487/rsrc/css/aphront/attached-file-view.css', 'type' => 'css', 'requires' => array( diff --git a/src/view/layout/filepreview/AphrontFilePreviewView.php b/src/view/layout/filepreview/AphrontFilePreviewView.php index c465fd9ac7..274d640e77 100644 --- a/src/view/layout/filepreview/AphrontFilePreviewView.php +++ b/src/view/layout/filepreview/AphrontFilePreviewView.php @@ -36,6 +36,7 @@ final class AphrontFilePreviewView extends AphrontView { 'src' => $file->getThumb160x120URI(), 'width' => 160, 'height' => 120, + 'title' => $file->getName(), )); $link = phutil_render_tag( 'a', @@ -45,12 +46,25 @@ final class AphrontFilePreviewView extends AphrontView { ), $img); + $display_name = $file->getName(); + if (strlen($display_name) > 22) { + $display_name = + substr($display_name, 0, 11). + "\xE2\x80\xA6". + substr($display_name, -9); + } + return '
'. $link. '
'. - phutil_escape_html($file->getName()). + phutil_render_tag( + 'span', + array( + 'title' => $file->getName(), + ), + phutil_escape_html($display_name)). '
'; } diff --git a/webroot/rsrc/css/aphront/attached-file-view.css b/webroot/rsrc/css/aphront/attached-file-view.css index b0d507bbb9..10cca14586 100644 --- a/webroot/rsrc/css/aphront/attached-file-view.css +++ b/webroot/rsrc/css/aphront/attached-file-view.css @@ -29,6 +29,9 @@ text-align: center; font-size: 11px; color: #333333; + overflow: hidden; + width: 166px; + white-space: nowrap; } .aphront-file-preview-thumb { @@ -36,4 +39,5 @@ border: 1px solid #000000; background: #ffffff; margin-bottom: 2px; + width: 160px; }