diff --git a/app/assets/javascripts/app/lib/mixins/view_helpers.coffee b/app/assets/javascripts/app/lib/mixins/view_helpers.coffee index 2d41d48e7..64686fd3c 100644 --- a/app/assets/javascripts/app/lib/mixins/view_helpers.coffee +++ b/app/assets/javascripts/app/lib/mixins/view_helpers.coffee @@ -155,6 +155,10 @@ App.ViewHelpers = return marked(string) App.i18n.translateContent(string) + ContentOrMimeType: (attachment) -> + types = ['Content-Type', 'content_type', 'Mime-Type', 'mime_type'] + _.values(_.pick(attachment?.preferences, types))[0] + ContentTypeIcon: (contentType) -> contentType = App.Utils.contentTypeCleanup(contentType) icons = diff --git a/app/assets/javascripts/app/views/generic/attachments.jst.eco b/app/assets/javascripts/app/views/generic/attachments.jst.eco index b1cc3907a..9f00bb4a7 100644 --- a/app/assets/javascripts/app/views/generic/attachments.jst.eco +++ b/app/assets/javascripts/app/views/generic/attachments.jst.eco @@ -9,7 +9,7 @@
<%- @humanFileSize(attachment.size) %>
<% else: %> - <% content_type = attachment.preferences['Content-Type'] || attachment.preferences['content_type'] %> + <% content_type = @ContentOrMimeType(attachment) %> download<% else: %>target="_blank"<% end %>>
<% if attachment.preferences && content_type && @ContentTypeIcon(content_type): %> @@ -28,4 +28,4 @@ <% end %> <% end %>
-<% end %> \ No newline at end of file +<% end %> diff --git a/app/assets/javascripts/app/views/ticket_zoom/sidebar_article_attachment.jst.eco b/app/assets/javascripts/app/views/ticket_zoom/sidebar_article_attachment.jst.eco index 7a0ba5748..b8bf35a33 100644 --- a/app/assets/javascripts/app/views/ticket_zoom/sidebar_article_attachment.jst.eco +++ b/app/assets/javascripts/app/views/ticket_zoom/sidebar_article_attachment.jst.eco @@ -1,13 +1,14 @@
<%- @humanTime(@article.created_at) %>
<% for attachment in @article.attachments: %> -
download<% end %>> + <% content_type = @ContentOrMimeType(attachment) %> + download<% end %>>
- <% if attachment.preferences && attachment.preferences['Content-Type'] && @ContentTypeIcon(attachment.preferences['Content-Type']): %> - <% if @canPreview(attachment.preferences['Content-Type']): %> + <% if content_type && @ContentTypeIcon(content_type): %> + <% if @canPreview(content_type): %> <% else: %> - <%- @Icon( @ContentTypeIcon(attachment.preferences['Content-Type']) ) %> + <%- @Icon( @ContentTypeIcon(content_type) ) %> <% end %> <% else: %> <%- @Icon('file-unknown') %> @@ -17,4 +18,4 @@
<%- @humanFileSize(attachment.size) %>
<% end %> -
\ No newline at end of file +