diff --git a/assets/default/css/theme.css b/assets/default/css/theme.css index e1cf19907be3026b7a44a7785173ecc49bb56622..97703547a176d6d917ed56dac636fc5d67feca49 100644 --- a/assets/default/css/theme.css +++ b/assets/default/css/theme.css @@ -885,7 +885,6 @@ a.refresh { #ticketThread .info a { display: inline-block; margin: 5px 10px 5px 0; - padding-left: 24px; height: 16px; line-height: 16px; background-position: 0 50%; @@ -1048,3 +1047,8 @@ img.sign-in-image { overflow: hidden; text-overflow: ellipsis; } +.image-hover a.action-button:hover, +.image-hover a.action-button { + color: initial !important; + text-decoration: none; +} diff --git a/include/class.format.php b/include/class.format.php index 06a07f5065e5ad5bcc5357833817eb9d37544fdd..b184b26cf842306e88fc243fa961ea10f0849921 100644 --- a/include/class.format.php +++ b/include/class.format.php @@ -366,7 +366,7 @@ class Format { }, 'schemes' => 'href: aim, feed, file, ftp, gopher, http, https, irc, mailto, news, nntp, sftp, ssh, telnet; *:file, http, https; src: cid, http, https, data', 'elements' => '*+iframe', - 'spec' => 'span=data-src,width,height', + 'spec' => 'span=data-src,width,height;img=data-cid', ); return Format::html($text, $config); } diff --git a/include/client/view.inc.php b/include/client/view.inc.php index 249f3058bbf7a5981116c86528ca0776ebaf2751..3b55a0fb65f2a1dc10843a57f15d18a19ccf1f27 100644 --- a/include/client/view.inc.php +++ b/include/client/view.inc.php @@ -128,16 +128,27 @@ if($ticket->getThreadCount() && ($thread=$ticket->getClientThread())) { </th></tr> <tr><td class="thread-body"><div><?php echo Format::clickableurls($entry->getBody()->toHtml()); ?></div></td></tr> <?php - if($entry->has_attachments - && ($urls = $entry->getAttachmentUrls()) - && ($links = $entry->getAttachmentsLinks())) { ?> - <tr><td class="info"><?php echo $links; ?></td></tr> -<?php } - if ($urls) { ?> - <script type="text/javascript"> - $(function() { showImagesInline(<?php echo - JsonDataEncoder::encode($urls); ?>); }); - </script> + $urls = null; + if ($entry->has_attachments + && ($urls = $entry->getAttachmentUrls())) { ?> + <tr> + <td class="info"><?php + foreach ($entry->attachments as $A) { + if ($A->inline) continue; + $size = ''; + if ($A->file->size) + $size = sprintf('<em>(%s)</em>', + Format::file_size($A->file->size)); +?> + <i class="icon-paperclip"></i> + <a class="no-pjax" href="<?php echo $A->file->getDownloadUrl(); + ?>" download="<?php echo Format::htmlchars($A->file->name); ?>" + target="_blank"> + <?php echo Format::htmlchars($A->file->name); + ?></a><?php echo $size;?> +<?php } ?> + </td> + </tr> <?php } ?> </table> <?php @@ -199,3 +210,18 @@ if (!$ticket->isClosed() || $ticket->isReopenable()) { ?> </form> <?php } ?> +<script type="text/javascript"> +<?php +// Hover support for all inline images +$urls = array(); +foreach (AttachmentFile::objects()->filter(array( + 'attachments__thread_entry__thread__id' => $ticket->getThreadId(), + 'attachments__inline' => true, +)) as $file) { + $urls[strtolower($file->getKey())] = array( + 'download_url' => $file->getDownloadUrl(), + 'filename' => $file->name, + ); +} ?> +showImagesInline(<?php echo JsonDataEncoder::encode($urls); ?>); +</script> diff --git a/js/osticket.js b/js/osticket.js index 911cbf4e758ab7b185837dfe8a51855e692d48c4..28fd56fc8fd5df9153eac06242e8116b8cdf5dc0 100644 --- a/js/osticket.js +++ b/js/osticket.js @@ -161,7 +161,9 @@ showImagesInline = function(urls, thread_id) { } ).append($('<div class="caption">') .append('<span class="filename">'+info.filename+'</span>') - .append('<a href="'+info.download_url+'" class="action-button pull-right"><i class="icon-download-alt"></i> ' + __('Download') + '</a>') + .append($('<a href="'+info.download_url+'" class="action-button pull-right"><i class="icon-download-alt"></i> ' + __('Download') + '</a>') + .attr('download', info.filename) + ) ); e.data('wrapped', true); }