diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_image_view.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_image_view.coffee index fc4223d14..df8661ed2 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_image_view.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_image_view.coffee @@ -12,7 +12,7 @@ class App.TicketZoomArticleImageView extends App.ControllerModal 'click .js-close': 'cancel' content: -> - "
#{@image}
" + "
#{@image}
" onSubmit: => url = "#{$(@image).attr('src')}?disposition=attachment" diff --git a/app/assets/javascripts/app/index.coffee b/app/assets/javascripts/app/index.coffee index 922403ef0..67af78fe7 100644 --- a/app/assets/javascripts/app/index.coffee +++ b/app/assets/javascripts/app/index.coffee @@ -137,6 +137,7 @@ class App extends Spine.Controller App.i18n.translateContent(string) ContentTypeIcon: (contentType) -> + contentType = App.Utils.contentTypeCleanup(contentType) icons = # image 'image/jpeg': 'file-image' @@ -172,6 +173,7 @@ class App extends Spine.Controller return icons[contentType] canDownload: (contentType) -> + contentType = App.Utils.contentTypeCleanup(contentType) contentType != 'text/html' canPreview: (contentType) -> diff --git a/app/assets/javascripts/app/lib/app_post/utils.coffee b/app/assets/javascripts/app/lib/app_post/utils.coffee index 134deb96e..b13c90189 100644 --- a/app/assets/javascripts/app/lib/app_post/utils.coffee +++ b/app/assets/javascripts/app/lib/app_post/utils.coffee @@ -913,6 +913,11 @@ class App.Utils result.push localResult[0] result + @contentTypeCleanup: (contentType) -> + return contentType if !contentType + contentType = contentType.replace(/^(.+?\/.+?)(\b|\s).+?$/, '$1') + contentType + @getRecipientArticle: (ticket, article, article_created_by, type, email_addresses = [], all) -> # empty form diff --git a/app/assets/stylesheets/zammad.scss b/app/assets/stylesheets/zammad.scss index 09a6dc9e5..74db894dc 100644 --- a/app/assets/stylesheets/zammad.scss +++ b/app/assets/stylesheets/zammad.scss @@ -7206,6 +7206,11 @@ label + .wizard-buttonList { opacity: 0; } +.imagePreview img { + max-width: 100%; + max-height: 100%; +} + .imageCropper p { margin: 0; } diff --git a/public/assets/tests/html_utils.js b/public/assets/tests/html_utils.js index bc8316d5b..1faef7d8c 100644 --- a/public/assets/tests/html_utils.js +++ b/public/assets/tests/html_utils.js @@ -2606,3 +2606,41 @@ test('check getRecipientArticle format', function() { }); } + +test("contentTypeCleanup", function() { + + var source = "image/png" + var should = "image/png" + var result = App.Utils.contentTypeCleanup(source) + equal(result, should, source) + + source = "image/png; some.file" + should = "image/png" + result = App.Utils.contentTypeCleanup(source) + equal(result, should, source) + + source = "image/png;some.file" + should = "image/png" + result = App.Utils.contentTypeCleanup(source) + equal(result, should, source) + + source = "image/jpeg;some.file" + should = "image/jpeg" + result = App.Utils.contentTypeCleanup(source) + equal(result, should, source) + + source = "image/jpg;some.file" + should = "image/jpg" + result = App.Utils.contentTypeCleanup(source) + equal(result, should, source) + + source = "image/gif;some.file" + should = "image/gif" + result = App.Utils.contentTypeCleanup(source) + equal(result, should, source) + + source = "image/gif\n;some.file" + should = "image/gif" + result = App.Utils.contentTypeCleanup(source) + equal(result, should, source) +}); \ No newline at end of file