Fixes #3309 - No icon / thumbnail for attached files when added via API
This commit is contained in:
parent
03b56b8fc8
commit
ad66cd9c1f
3 changed files with 12 additions and 7 deletions
|
@ -155,6 +155,10 @@ App.ViewHelpers =
|
||||||
return marked(string)
|
return marked(string)
|
||||||
App.i18n.translateContent(string)
|
App.i18n.translateContent(string)
|
||||||
|
|
||||||
|
ContentOrMimeType: (attachment) ->
|
||||||
|
types = ['Content-Type', 'content_type', 'Mime-Type', 'mime_type']
|
||||||
|
_.values(_.pick(attachment?.preferences, types))[0]
|
||||||
|
|
||||||
ContentTypeIcon: (contentType) ->
|
ContentTypeIcon: (contentType) ->
|
||||||
contentType = App.Utils.contentTypeCleanup(contentType)
|
contentType = App.Utils.contentTypeCleanup(contentType)
|
||||||
icons =
|
icons =
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<div class="attachment-size"><%- @humanFileSize(attachment.size) %></div>
|
<div class="attachment-size"><%- @humanFileSize(attachment.size) %></div>
|
||||||
</div>
|
</div>
|
||||||
<% else: %>
|
<% else: %>
|
||||||
<% content_type = attachment.preferences['Content-Type'] || attachment.preferences['content_type'] %>
|
<% content_type = @ContentOrMimeType(attachment) %>
|
||||||
<a class="attachment attachment--preview" href="<%= attachment.url %>" data-type="attachment"<% if @canDownload(content_type): %> download<% else: %>target="_blank"<% end %>>
|
<a class="attachment attachment--preview" href="<%= attachment.url %>" data-type="attachment"<% if @canDownload(content_type): %> download<% else: %>target="_blank"<% end %>>
|
||||||
<div class="attachment-icon">
|
<div class="attachment-icon">
|
||||||
<% if attachment.preferences && content_type && @ContentTypeIcon(content_type): %>
|
<% if attachment.preferences && content_type && @ContentTypeIcon(content_type): %>
|
||||||
|
@ -28,4 +28,4 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
<div class="attachments-block js-attachments">
|
<div class="attachments-block js-attachments">
|
||||||
<div class="attachments-block-headline"><%- @humanTime(@article.created_at) %></div>
|
<div class="attachments-block-headline"><%- @humanTime(@article.created_at) %></div>
|
||||||
<% for attachment in @article.attachments: %>
|
<% for attachment in @article.attachments: %>
|
||||||
<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 = @ContentOrMimeType(attachment) %>
|
||||||
|
<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">
|
<div class="attachment-icon">
|
||||||
<% if attachment.preferences && attachment.preferences['Content-Type'] && @ContentTypeIcon(attachment.preferences['Content-Type']): %>
|
<% if content_type && @ContentTypeIcon(content_type): %>
|
||||||
<% if @canPreview(attachment.preferences['Content-Type']): %>
|
<% if @canPreview(content_type): %>
|
||||||
<img src="<%= App.Config.get('api_path') %>/ticket_attachment/<%= @article.ticket_id %>/<%= @article.id %>/<%= attachment.id %>?view=preview">
|
<img src="<%= App.Config.get('api_path') %>/ticket_attachment/<%= @article.ticket_id %>/<%= @article.id %>/<%= attachment.id %>?view=preview">
|
||||||
<% else: %>
|
<% else: %>
|
||||||
<%- @Icon( @ContentTypeIcon(attachment.preferences['Content-Type']) ) %>
|
<%- @Icon( @ContentTypeIcon(content_type) ) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else: %>
|
<% else: %>
|
||||||
<%- @Icon('file-unknown') %>
|
<%- @Icon('file-unknown') %>
|
||||||
|
@ -17,4 +18,4 @@
|
||||||
<div class="attachment-size"><%- @humanFileSize(attachment.size) %></div>
|
<div class="attachment-size"><%- @humanFileSize(attachment.size) %></div>
|
||||||
</a>
|
</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue