From b8890aee25ba43cb1257f533493ed72e2f413f27 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Thu, 4 Oct 2018 22:30:43 +0200 Subject: [PATCH] Safe(r) handling of invalid images in the image cropper --- .../ImageCropperPropertyValueEditor.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyValueEditor.cs b/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyValueEditor.cs index ccee138486..dc9c6f38e6 100644 --- a/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyValueEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyValueEditor.cs @@ -158,8 +158,16 @@ namespace Umbraco.Web.PropertyEditors { var preValues = editorValue.PreValues.FormatAsDictionary(); var sizes = preValues.Any() ? preValues.First().Value.Value : string.Empty; - using (var image = Image.FromStream(filestream)) - _mediaFileSystem.GenerateThumbnails(image, filepath, sizes); + try + { + using (var image = Image.FromStream(filestream)) + _mediaFileSystem.GenerateThumbnails(image, filepath, sizes); + } + catch (ArgumentException ex) + { + // send any argument errors caused by the thumbnail generation to the log instead of failing miserably + LogHelper.WarnWithException("Could not extract image thumbnails.", ex); + } } // all related properties (auto-fill) are managed by ImageCropperPropertyEditor