From 49395ec5772c86f8929ed9bcb5c1e589c3a7af31 Mon Sep 17 00:00:00 2001 From: Dan Ungureanu Date: Wed, 25 Mar 2020 12:59:16 +0200 Subject: [PATCH] FIX: Fix image optimization pipeline (#9257) * FIX: Do not use original filename to extract the original filename Prefer extracting filename from the destination path, which is build using extracted image information. * UX: Show better error images --- config/locales/server.en.yml | 1 + lib/upload_creator.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 6d1c849522a..986905fba13 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -3734,6 +3734,7 @@ en: file_missing: "Sorry, you must provide a file to upload." empty: "Sorry, but the file you provided is empty." png_to_jpg_conversion_failure_message: "An error happened when converting from PNG to JPG." + optimize_failure_message: "An error occured while optimizing the uploaded image." attachments: too_large: "Sorry, the file you are trying to upload is too big (maximum size is %{max_size_kb}KB)." images: diff --git a/lib/upload_creator.rb b/lib/upload_creator.rb index 9c66754861a..d9c21f19202 100644 --- a/lib/upload_creator.rb +++ b/lib/upload_creator.rb @@ -252,7 +252,6 @@ class UploadCreator from, to, "50%", - filename: @filename, allow_animation: allow_animation, raise_on_error: true ) @@ -264,6 +263,8 @@ class UploadCreator return if filesize >= original_size || pixels == 0 || !should_downsize? end + rescue + @upload.errors.add(:base, I18n.t("upload.optimize_failure_message")) end def is_still_too_big?