diff --git a/app/assets/javascripts/discourse/lib/utilities.js.es6 b/app/assets/javascripts/discourse/lib/utilities.js.es6 index 5eeb3a358c4..639c222fd4d 100644 --- a/app/assets/javascripts/discourse/lib/utilities.js.es6 +++ b/app/assets/javascripts/discourse/lib/utilities.js.es6 @@ -170,7 +170,7 @@ export function validateUploadedFiles(files, opts) { // CHROME ONLY: if the image was pasted, sets its name to a default one if (typeof Blob !== "undefined" && typeof File !== "undefined") { - if (upload instanceof Blob && !(upload instanceof File) && upload.type === "image/png") { upload.name = "blob.png"; } + if (upload instanceof Blob && !(upload instanceof File) && upload.type === "image/png") { upload.name = "__blob__.png"; } } opts = opts || {}; diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index 57f19f151fd..52659537e29 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -74,13 +74,14 @@ class UploadsController < ApplicationController return { errors: I18n.t("upload.file_missing") } if tempfile.nil? # convert pasted images to HQ jpegs - if filename == "blob.png" && SiteSetting.convert_pasted_images_to_hq_jpg - jpeg_path = "#{File.dirname(tempfile.path)}/blob.jpg" + byebug + if filename == "__blob__.png" && SiteSetting.convert_pasted_images_to_hq_jpg + jpeg_path = "#{File.dirname(tempfile.path)}/image.jpg" OptimizedImage.ensure_safe_paths!(tempfile.path, jpeg_path) `convert #{tempfile.path} -quality #{SiteSetting.convert_pasted_images_quality} #{jpeg_path}` # only change the format of the image when JPG is at least 5% smaller if File.size(jpeg_path) < File.size(tempfile.path) * 0.95 - filename = "blob.jpg" + filename = "image.jpg" content_type = "image/jpeg" tempfile = File.open(jpeg_path) else