From 5d9bde807e125843e02702a94b146d1099543074 Mon Sep 17 00:00:00 2001 From: Wincent Date: Sat, 31 Oct 2015 16:29:02 +0100 Subject: [PATCH 1/5] Changes GetBigThumbnail to image processor in mediahelper.service.js and fileupload.controller.js Changed ImageController.GetBigThumbnail to redirect Changed thumbnail paths to include rnd equal to UpdateDate --- .../fileupload/fileupload.controller.js | 47 ++- src/Umbraco.Web/Editors/ImagesController.cs | 293 +++++++----------- 2 files changed, 141 insertions(+), 199 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/fileupload/fileupload.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/fileupload/fileupload.controller.js index 37dea64c21..d62d76c982 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/fileupload/fileupload.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/fileupload/fileupload.controller.js @@ -144,31 +144,28 @@ function fileUploadController($scope, $element, $compile, imageHelper, fileManag }; angular.module("umbraco") .controller('Umbraco.PropertyEditors.FileUploadController', fileUploadController) - .run(function(mediaHelper, umbRequestHelper){ + .run(function(mediaHelper, umbRequestHelper, assetsService){ if (mediaHelper && mediaHelper.registerFileResolver) { - - //NOTE: The 'entity' can be either a normal media entity or an "entity" returned from the entityResource - // they contain different data structures so if we need to query against it we need to be aware of this. - mediaHelper.registerFileResolver("Umbraco.UploadField", function(property, entity, thumbnail){ - if (thumbnail) { - - if (mediaHelper.detectIfImageByExtension(property.value)) { - - var thumbnailUrl = umbRequestHelper.getApiUrl( - "imagesApiBaseUrl", - "GetBigThumbnail", - [{ originalImagePath: property.value }]); - - return thumbnailUrl; - } - else { - return null; - } - + assetsService.load(["lib/moment/moment-with-locales.js"]).then( + function () { + //NOTE: The 'entity' can be either a normal media entity or an "entity" returned from the entityResource + // they contain different data structures so if we need to query against it we need to be aware of this. + mediaHelper.registerFileResolver("Umbraco.UploadField", function(property, entity, thumbnail){ + if (thumbnail) { + if (mediaHelper.detectIfImageByExtension(property.value)) { + //get default big thumbnail from image processor + var thumbnailUrl = property.value + "?rnd=" + moment(entity.updateDate).format("YYYYMMDDHHmmss") + "&width=500"; + return thumbnailUrl; + } + else { + return null; + } + } + else { + return property.value; + } + }); } - else { - return property.value; - } - }); + ); } - }); \ No newline at end of file + }); diff --git a/src/Umbraco.Web/Editors/ImagesController.cs b/src/Umbraco.Web/Editors/ImagesController.cs index 39960317b1..d437b08ecc 100644 --- a/src/Umbraco.Web/Editors/ImagesController.cs +++ b/src/Umbraco.Web/Editors/ImagesController.cs @@ -1,175 +1,120 @@ -using System; -using System.Drawing; -using System.IO; -using System.Net; -using System.Net.Http; -using System.Net.Http.Headers; -using Umbraco.Core; -using Umbraco.Core.Configuration; -using Umbraco.Core.IO; -using Umbraco.Core.Media; -using Umbraco.Web.Mvc; -using Umbraco.Web.WebApi; -using Umbraco.Web.WebApi.Filters; -using Constants = Umbraco.Core.Constants; - -namespace Umbraco.Web.Editors -{ - /// - /// A controller used to return images for media - /// - [PluginController("UmbracoApi")] - public class ImagesController : UmbracoAuthorizedApiController - { - /// - /// Gets the big thumbnail image for the media id - /// - /// - /// - /// - /// If there is no media, image property or image file is found then this will return not found. - /// - public HttpResponseMessage GetBigThumbnail(int mediaId) - { - var media = Services.MediaService.GetById(mediaId); - if (media == null) - { - return Request.CreateResponse(HttpStatusCode.NotFound); - } - var imageProp = media.Properties[Constants.Conventions.Media.File]; - if (imageProp == null) - { - return Request.CreateResponse(HttpStatusCode.NotFound); - } - - var imagePath = imageProp.Value.ToString(); - - return GetBigThumbnail(imagePath); - } - - /// - /// Gets the big thumbnail image for the original image path - /// - /// - /// - /// - /// If there is no original image is found then this will return not found. - /// - public HttpResponseMessage GetBigThumbnail(string originalImagePath) - { - if (string.IsNullOrWhiteSpace(originalImagePath)) - return Request.CreateResponse(HttpStatusCode.OK); - - return GetResized(originalImagePath, 500, "big-thumb"); - } - - /// - /// Gets a resized image for the media id - /// - /// - /// - /// - /// - /// If there is no media, image property or image file is found then this will return not found. - /// - public HttpResponseMessage GetResized(int mediaId, int width) - { - var media = Services.MediaService.GetById(mediaId); - if (media == null) - { - return new HttpResponseMessage(HttpStatusCode.NotFound); - } - var imageProp = media.Properties[Constants.Conventions.Media.File]; - if (imageProp == null) - { - return new HttpResponseMessage(HttpStatusCode.NotFound); - } - - var imagePath = imageProp.Value.ToString(); - - return GetResized(imagePath, width); - } - - /// - /// Gets a resized image for the image at the given path - /// - /// - /// - /// - /// - /// If there is no media, image property or image file is found then this will return not found. - /// - public HttpResponseMessage GetResized(string imagePath, int width) - { - return GetResized(imagePath, width, Convert.ToString(width)); - } - - //TODO: We should delegate this to ImageProcessing - - /// - /// Gets a resized image - if the requested max width is greater than the original image, only the original image will be returned. - /// - /// - /// - /// - /// - private HttpResponseMessage GetResized(string imagePath, int width, string suffix) - { - var mediaFileSystem = FileSystemProviderManager.Current.GetFileSystemProvider(); - var ext = Path.GetExtension(imagePath); - - //we need to check if it is an image by extension - if (UmbracoConfig.For.UmbracoSettings().Content.ImageFileTypes.InvariantContains(ext.TrimStart('.')) == false) - { - return Request.CreateResponse(HttpStatusCode.NotFound); - } - - var thumbFilePath = imagePath.TrimEnd(ext) + "_" + suffix + ".jpg"; - var fullOrgPath = mediaFileSystem.GetFullPath(mediaFileSystem.GetRelativePath(imagePath)); - var fullNewPath = mediaFileSystem.GetFullPath(mediaFileSystem.GetRelativePath(thumbFilePath)); - var thumbIsNew = mediaFileSystem.FileExists(fullNewPath) == false; - if (thumbIsNew) - { - //we need to generate it - if (mediaFileSystem.FileExists(fullOrgPath) == false) - { - return Request.CreateResponse(HttpStatusCode.NotFound); - } - - using (var fileStream = mediaFileSystem.OpenFile(fullOrgPath)) - { - if (fileStream.CanSeek) fileStream.Seek(0, 0); - using (var originalImage = Image.FromStream(fileStream)) - { - //If it is bigger, then do the resize - if (originalImage.Width >= width && originalImage.Height >= width) - { - ImageHelper.GenerateThumbnail( - originalImage, - width, - fullNewPath, - "jpg", - mediaFileSystem); - } - else - { - //just return the original image - fullNewPath = fullOrgPath; - } - - } - } - } - - var result = Request.CreateResponse(HttpStatusCode.OK); - //NOTE: That we are not closing this stream as the framework will do that for us, if we try it will - // fail. See http://stackoverflow.com/questions/9541351/returning-binary-file-from-controller-in-asp-net-web-api - var stream = mediaFileSystem.OpenFile(fullNewPath); - if (stream.CanSeek) stream.Seek(0, 0); - result.Content = new StreamContent(stream); - result.Headers.Date = mediaFileSystem.GetLastModified(imagePath); - result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg"); - return result; - } - } +using System; +using System.Drawing; +using System.IO; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using Umbraco.Core; +using Umbraco.Core.Configuration; +using Umbraco.Core.IO; +using Umbraco.Core.Media; +using Umbraco.Core.Models; +using Umbraco.Web.Mvc; +using Umbraco.Web.WebApi; +using Umbraco.Web.WebApi.Filters; +using Constants = Umbraco.Core.Constants; + +namespace Umbraco.Web.Editors +{ + /// + /// A controller used to return images for media + /// + [PluginController("UmbracoApi")] + public class ImagesController : UmbracoAuthorizedApiController + { + /// + /// Gets the big thumbnail image for the media id + /// + /// + /// + /// + /// If there is no media, image property or image file is found then this will return not found. + /// + public HttpResponseMessage GetBigThumbnail(int mediaId) + { + var media = Services.MediaService.GetById(mediaId); + if (media == null) + { + return Request.CreateResponse(HttpStatusCode.NotFound); + } + + return GetResized(media, 500); + } + + /// + /// Gets the big thumbnail image for the original image path + /// + /// + /// + /// + /// If there is no original image is found then this will return not found. + /// + public HttpResponseMessage GetBigThumbnail(string originalImagePath) + { + if (string.IsNullOrWhiteSpace(originalImagePath)) + return Request.CreateResponse(HttpStatusCode.OK); + + return GetResized(originalImagePath, 500); + } + + /// + /// Gets a resized image for the media id + /// + /// + /// + /// + /// + /// If there is no media, image property or image file is found then this will return not found. + /// + public HttpResponseMessage GetResized(int mediaId, int width) + { + var media = Services.MediaService.GetById(mediaId); + if (media == null) + { + return new HttpResponseMessage(HttpStatusCode.NotFound); + } + + return GetResized( media, 500 ); + } + + /// + /// Gets a resized image for the image at the given path + /// + /// + /// + /// + /// + /// If there is no media, image property or image file is found then this will return not found. + /// + public HttpResponseMessage GetResized(string imagePath, int width) + { + var media = Services.MediaService.GetMediaByPath( imagePath ); + if (media == null) + { + return new HttpResponseMessage( HttpStatusCode.NotFound ); + } + + return GetResized( media, 500 ); + } + + /// + /// Gets a resized image by redirecting to ImageProcessor + /// + /// + /// + /// + private HttpResponseMessage GetResized(IMedia media, int width) + { + var imageProp = media.Properties[Constants.Conventions.Media.File]; + if (imageProp == null) + { + return Request.CreateResponse( HttpStatusCode.NotFound ); + } + + var imagePath = imageProp.Value.ToString(); + var response = Request.CreateResponse( HttpStatusCode.Found ); + response.Headers.Location = new Uri( string.Format( "{0}?rnd={1}&width={2}", imagePath, string.Format( "{0:yyyyMMddHHmmss}", media.UpdateDate ), width ), UriKind.Relative ); + return response; + } + } } \ No newline at end of file From 2664a75c84d11711ccb3efaf11638b771c65289c Mon Sep 17 00:00:00 2001 From: Wincent Date: Tue, 10 Nov 2015 21:09:34 +0100 Subject: [PATCH 2/5] Removed generation of old thumbnails --- .../FileUploadPropertyValueEditor.cs | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/src/Umbraco.Web/PropertyEditors/FileUploadPropertyValueEditor.cs b/src/Umbraco.Web/PropertyEditors/FileUploadPropertyValueEditor.cs index e4ff4da1d6..775cf67c77 100644 --- a/src/Umbraco.Web/PropertyEditors/FileUploadPropertyValueEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/FileUploadPropertyValueEditor.cs @@ -128,29 +128,6 @@ namespace Umbraco.Web.PropertyEditors { var umbracoFile = UmbracoMediaFile.Save(fileStream, fileName); - if (umbracoFile.SupportsResizing) - { - var additionalSizes = new List(); - //get the pre-vals value - var thumbs = editorValue.PreValues.FormatAsDictionary(); - if (thumbs.Any()) - { - var thumbnailSizes = thumbs.First().Value.Value; - // additional thumbnails configured as prevalues on the DataType - foreach (var thumb in thumbnailSizes.Split(new[] { ";", "," }, StringSplitOptions.RemoveEmptyEntries)) - { - int thumbSize; - if (thumb == "" || int.TryParse(thumb, out thumbSize) == false) continue; - additionalSizes.Add(thumbSize); - } - } - - using (var image = Image.FromStream(fileStream)) - { - ImageHelper.GenerateMediaThumbnails(fs, fileName, umbracoFile.Extension, image, additionalSizes); - } - - } newValue.Add(umbracoFile.Url); //add to the saved paths savedFilePaths.Add(umbracoFile.Url); From e0ee786271e334116fafc58b25127caf6cc1320f Mon Sep 17 00:00:00 2001 From: Wincent Date: Fri, 4 Dec 2015 09:31:39 +0100 Subject: [PATCH 3/5] Re-enables support for non media thumbnails --- src/Umbraco.Web/Editors/ImagesController.cs | 250 ++++++++++---------- 1 file changed, 131 insertions(+), 119 deletions(-) diff --git a/src/Umbraco.Web/Editors/ImagesController.cs b/src/Umbraco.Web/Editors/ImagesController.cs index d437b08ecc..73389c0185 100644 --- a/src/Umbraco.Web/Editors/ImagesController.cs +++ b/src/Umbraco.Web/Editors/ImagesController.cs @@ -1,120 +1,132 @@ -using System; -using System.Drawing; -using System.IO; -using System.Net; -using System.Net.Http; -using System.Net.Http.Headers; -using Umbraco.Core; -using Umbraco.Core.Configuration; -using Umbraco.Core.IO; -using Umbraco.Core.Media; -using Umbraco.Core.Models; -using Umbraco.Web.Mvc; -using Umbraco.Web.WebApi; -using Umbraco.Web.WebApi.Filters; -using Constants = Umbraco.Core.Constants; - -namespace Umbraco.Web.Editors -{ - /// - /// A controller used to return images for media - /// - [PluginController("UmbracoApi")] - public class ImagesController : UmbracoAuthorizedApiController - { - /// - /// Gets the big thumbnail image for the media id - /// - /// - /// - /// - /// If there is no media, image property or image file is found then this will return not found. - /// - public HttpResponseMessage GetBigThumbnail(int mediaId) - { - var media = Services.MediaService.GetById(mediaId); - if (media == null) - { - return Request.CreateResponse(HttpStatusCode.NotFound); - } - - return GetResized(media, 500); - } - - /// - /// Gets the big thumbnail image for the original image path - /// - /// - /// - /// - /// If there is no original image is found then this will return not found. - /// - public HttpResponseMessage GetBigThumbnail(string originalImagePath) - { - if (string.IsNullOrWhiteSpace(originalImagePath)) - return Request.CreateResponse(HttpStatusCode.OK); - - return GetResized(originalImagePath, 500); - } - - /// - /// Gets a resized image for the media id - /// - /// - /// - /// - /// - /// If there is no media, image property or image file is found then this will return not found. - /// - public HttpResponseMessage GetResized(int mediaId, int width) - { - var media = Services.MediaService.GetById(mediaId); - if (media == null) - { - return new HttpResponseMessage(HttpStatusCode.NotFound); - } - - return GetResized( media, 500 ); - } - - /// - /// Gets a resized image for the image at the given path - /// - /// - /// - /// - /// - /// If there is no media, image property or image file is found then this will return not found. - /// - public HttpResponseMessage GetResized(string imagePath, int width) - { - var media = Services.MediaService.GetMediaByPath( imagePath ); - if (media == null) - { - return new HttpResponseMessage( HttpStatusCode.NotFound ); - } - - return GetResized( media, 500 ); - } - - /// - /// Gets a resized image by redirecting to ImageProcessor - /// - /// - /// - /// - private HttpResponseMessage GetResized(IMedia media, int width) - { - var imageProp = media.Properties[Constants.Conventions.Media.File]; - if (imageProp == null) - { - return Request.CreateResponse( HttpStatusCode.NotFound ); - } - - var imagePath = imageProp.Value.ToString(); - var response = Request.CreateResponse( HttpStatusCode.Found ); - response.Headers.Location = new Uri( string.Format( "{0}?rnd={1}&width={2}", imagePath, string.Format( "{0:yyyyMMddHHmmss}", media.UpdateDate ), width ), UriKind.Relative ); - return response; - } - } +using System; +using System.Drawing; +using System.IO; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using Umbraco.Core; +using Umbraco.Core.Configuration; +using Umbraco.Core.IO; +using Umbraco.Core.Media; +using Umbraco.Web.Mvc; +using Umbraco.Web.WebApi; +using Umbraco.Web.WebApi.Filters; +using Constants = Umbraco.Core.Constants; + +namespace Umbraco.Web.Editors +{ + /// + /// A controller used to return images for media + /// + [PluginController("UmbracoApi")] + public class ImagesController : UmbracoAuthorizedApiController + { + /// + /// Gets the big thumbnail image for the media id + /// + /// + /// + /// + /// If there is no media, image property or image file is found then this will return not found. + /// + public HttpResponseMessage GetBigThumbnail(int mediaId) + { + var media = Services.MediaService.GetById(mediaId); + if (media == null) + { + return Request.CreateResponse(HttpStatusCode.NotFound); + } + var imageProp = media.Properties[Constants.Conventions.Media.File]; + if (imageProp == null) + { + return Request.CreateResponse(HttpStatusCode.NotFound); + } + + var imagePath = imageProp.Value.ToString(); + + return GetBigThumbnail(imagePath); + } + + /// + /// Gets the big thumbnail image for the original image path + /// + /// + /// + /// + /// If there is no original image is found then this will return not found. + /// + public HttpResponseMessage GetBigThumbnail(string originalImagePath) + { + if (string.IsNullOrWhiteSpace(originalImagePath)) + return Request.CreateResponse(HttpStatusCode.OK); + + return GetResized(originalImagePath, 500, "big-thumb"); + } + + /// + /// Gets a resized image for the media id + /// + /// + /// + /// + /// + /// If there is no media, image property or image file is found then this will return not found. + /// + public HttpResponseMessage GetResized(int mediaId, int width) + { + var media = Services.MediaService.GetById(mediaId); + if (media == null) + { + return new HttpResponseMessage(HttpStatusCode.NotFound); + } + var imageProp = media.Properties[Constants.Conventions.Media.File]; + if (imageProp == null) + { + return new HttpResponseMessage(HttpStatusCode.NotFound); + } + + var imagePath = imageProp.Value.ToString(); + + return GetResized(imagePath, width); + } + + /// + /// Gets a resized image for the image at the given path + /// + /// + /// + /// + /// + /// If there is no media, image property or image file is found then this will return not found. + /// + public HttpResponseMessage GetResized(string imagePath, int width) + { + return GetResized(imagePath, width, Convert.ToString(width)); + } + + /// + /// Gets a resized image - if the requested max width is greater than the original image, only the original image will be returned. + /// + /// + /// + /// + /// + private HttpResponseMessage GetResized(string imagePath, int width, string suffix) + { + var mediaFileSystem = FileSystemProviderManager.Current.GetFileSystemProvider(); + var ext = Path.GetExtension(imagePath); + + //we need to check if it is an image by extension + if (UmbracoConfig.For.UmbracoSettings().Content.ImageFileTypes.InvariantContains(ext.TrimStart('.')) == false) + { + return Request.CreateResponse(HttpStatusCode.NotFound); + } + + //redirect to ImageProcessor thumbnail with rnd generated from last write time of original media file + var fullOrgPath = mediaFileSystem.GetFullPath(mediaFileSystem.GetRelativePath(imagePath)); + var response = Request.CreateResponse( HttpStatusCode.Found ); + response.Headers.Location = new Uri( string.Format( "{0}?rnd={1}&width={2}", imagePath, string.Format( "{0:yyyyMMddHHmmss}", System.IO.File.GetLastWriteTime( fullOrgPath ) ), width ), UriKind.Relative ); + return response; + } + } } \ No newline at end of file From 96b24d7ee07a3a462c9b5d598637354830e60db6 Mon Sep 17 00:00:00 2001 From: Wincent Date: Thu, 31 Dec 2015 12:01:35 +0100 Subject: [PATCH 4/5] Removes dependency to System.IO.File --- src/Umbraco.Web/Editors/ImagesController.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web/Editors/ImagesController.cs b/src/Umbraco.Web/Editors/ImagesController.cs index 73389c0185..416ffc2553 100644 --- a/src/Umbraco.Web/Editors/ImagesController.cs +++ b/src/Umbraco.Web/Editors/ImagesController.cs @@ -122,10 +122,10 @@ namespace Umbraco.Web.Editors return Request.CreateResponse(HttpStatusCode.NotFound); } - //redirect to ImageProcessor thumbnail with rnd generated from last write time of original media file - var fullOrgPath = mediaFileSystem.GetFullPath(mediaFileSystem.GetRelativePath(imagePath)); + //redirect to ImageProcessor thumbnail with rnd generated from last modified time of original media file var response = Request.CreateResponse( HttpStatusCode.Found ); - response.Headers.Location = new Uri( string.Format( "{0}?rnd={1}&width={2}", imagePath, string.Format( "{0:yyyyMMddHHmmss}", System.IO.File.GetLastWriteTime( fullOrgPath ) ), width ), UriKind.Relative ); + var imageLastModified = mediaFileSystem.GetLastModified( imagePath ); + response.Headers.Location = new Uri( string.Format( "{0}?rnd={1}&width={2}", imagePath, string.Format( "{0:yyyyMMddHHmmss}", imageLastModified ), width ), UriKind.Relative ); return response; } } From 9bfac0fdcdc5a397e938ca06fe924e63a1f9c8ed Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 12 Jan 2016 14:20:25 +0100 Subject: [PATCH 5/5] Still create the thumbnails upon upload (for backwards compatibility) --- .../FileUploadPropertyValueEditor.cs | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web/PropertyEditors/FileUploadPropertyValueEditor.cs b/src/Umbraco.Web/PropertyEditors/FileUploadPropertyValueEditor.cs index 775cf67c77..221dde865f 100644 --- a/src/Umbraco.Web/PropertyEditors/FileUploadPropertyValueEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/FileUploadPropertyValueEditor.cs @@ -63,10 +63,10 @@ namespace Umbraco.Web.PropertyEditors clear = json["clearFiles"].Value(); } - var currentPersistedValues = new string[] {}; + var currentPersistedValues = new string[] { }; if (string.IsNullOrEmpty(currentValue.ToString()) == false) { - currentPersistedValues = currentValue.ToString().Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries); + currentPersistedValues = currentValue.ToString().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } var newValue = new List(); @@ -82,7 +82,7 @@ namespace Umbraco.Web.PropertyEditors } return ""; } - + //check for any files if (editorValue.AdditionalData.ContainsKey("files")) { @@ -128,20 +128,43 @@ namespace Umbraco.Web.PropertyEditors { var umbracoFile = UmbracoMediaFile.Save(fileStream, fileName); + if (umbracoFile.SupportsResizing) + { + var additionalSizes = new List(); + //get the pre-vals value + var thumbs = editorValue.PreValues.FormatAsDictionary(); + if (thumbs.Any()) + { + var thumbnailSizes = thumbs.First().Value.Value; + // additional thumbnails configured as prevalues on the DataType + foreach (var thumb in thumbnailSizes.Split(new[] { ";", "," }, StringSplitOptions.RemoveEmptyEntries)) + { + int thumbSize; + if (thumb == "" || int.TryParse(thumb, out thumbSize) == false) continue; + additionalSizes.Add(thumbSize); + } + } + + using (var image = Image.FromStream(fileStream)) + { + ImageHelper.GenerateMediaThumbnails(fs, fileName, umbracoFile.Extension, image, additionalSizes); + } + } + newValue.Add(umbracoFile.Url); //add to the saved paths savedFilePaths.Add(umbracoFile.Url); } //now remove the temp file - File.Delete(file.TempFilePath); + File.Delete(file.TempFilePath); } - + //Remove any files that are no longer saved for this item foreach (var toRemove in currentPersistedValues.Except(savedFilePaths)) { fs.DeleteFile(fs.GetRelativePath(toRemove), true); } - + return string.Join(",", newValue); }