Improved content type detection for image preview of attachments.

This commit is contained in:
Martin Edenhofer 2019-02-19 07:03:48 +01:00
parent 5b24e7beaf
commit 3e50a06306

View file

@ -62,13 +62,14 @@
<div class="attachment-size"><%- @humanFileSize(attachment.size) %></div>
</div>
<% else: %>
<a class="attachment attachment--preview" title="<%- attachment.preferences['Content-Type'] %>" target="_blank" href="<%= App.Config.get('api_path') %>/ticket_attachment/<%= @article.ticket_id %>/<%= @article.id %>/<%= attachment.id %>?disposition=attachment" data-type="attachment"<% if @canDownload(attachment.preferences['Content-Type']): %> download<% end %>>
<% content_type = attachment.preferences['Content-Type'] || attachment.preferences['content_type'] %>
<a class="attachment attachment--preview" title="<%- content_type %>" target="_blank" href="<%= App.Config.get('api_path') %>/ticket_attachment/<%= @article.ticket_id %>/<%= @article.id %>/<%= attachment.id %>?disposition=attachment" data-type="attachment"<% if @canDownload(content_type): %> download<% end %>>
<div class="attachment-icon">
<% if attachment.preferences && attachment.preferences['Content-Type'] && @ContentTypeIcon(attachment.preferences['Content-Type']): %>
<% if @canPreview(attachment.preferences['Content-Type']): %>
<% if attachment.preferences && content_type && @ContentTypeIcon(content_type): %>
<% if @canPreview(content_type): %>
<img src="<%= App.Config.get('api_path') %>/ticket_attachment/<%= @article.ticket_id %>/<%= @article.id %>/<%= attachment.id %>?view=preview">
<% else: %>
<%- @Icon( @ContentTypeIcon(attachment.preferences['Content-Type']) ) %>
<%- @Icon( @ContentTypeIcon(content_type) ) %>
<% end %>
<% else: %>
<%- @Icon('file-unknown') %>