From df6e29a24931f3214cdbd50015c6dd4ce2b73695 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Sun, 29 Sep 2019 14:55:39 +0200 Subject: [PATCH] Uses just the fix from #6414 - to show a preview of svg files after selection in the media picker --- .../common/services/mediahelper.service.js | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/services/mediahelper.service.js b/src/Umbraco.Web.UI.Client/src/common/services/mediahelper.service.js index c8acdec353..97e4830408 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/mediahelper.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/mediahelper.service.js @@ -143,23 +143,28 @@ function mediaHelper(umbRequestHelper, $log) { */ resolveFileFromEntity: function (mediaEntity, thumbnail) { - if (!angular.isObject(mediaEntity.metaData) || !mediaEntity.metaData.MediaPath) { + var mediaPath = angular.isObject(mediaEntity.metaData) ? mediaEntity.metaData.MediaPath : null; + + if (!mediaPath) { //don't throw since this image legitimately might not contain a media path, but output a warning $log.warn("Cannot resolve the file url from the mediaEntity, it does not contain the required metaData"); return null; } if (thumbnail) { - if (this.detectIfImageByExtension(mediaEntity.metaData.MediaPath)) { - return this.getThumbnailFromPath(mediaEntity.metaData.MediaPath); + if (this.detectIfImageByExtension(mediaPath)) { + return this.getThumbnailFromPath(mediaPath); + } + else if (this.getFileExtension(mediaPath) === "svg") { + return this.getThumbnailFromPath(mediaPath); } else { return null; } } else { - return mediaEntity.metaData.MediaPath; - } + return mediaPath; + } }, /** @@ -294,6 +299,11 @@ function mediaHelper(umbRequestHelper, $log) { */ getThumbnailFromPath: function (imagePath) { + // Check if file is a svg + if (this.getFileExtension(imagePath) === "svg") { + return imagePath; + } + //If the path is not an image we cannot get a thumb if (!this.detectIfImageByExtension(imagePath)) { return null;