diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/upload/umbpropertyfileupload.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/upload/umbpropertyfileupload.directive.js index b3094d9dab..83c2032e7d 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/upload/umbpropertyfileupload.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/upload/umbpropertyfileupload.directive.js @@ -22,7 +22,16 @@ vm.files = []; //notify the callback - vm.onValueChanged({ value: null }); + notifyValueChanged(null); + } + + function notifyValueChanged(val) { + + //notify the callback + vm.onValueChanged({ value: val }); + + //need to explicity setDirty here to track changes + vm.fileUploadForm.$setDirty(); } /** Called when the component initializes */ @@ -119,10 +128,7 @@ return null; } - var thumbnailUrl = umbRequestHelper.getApiUrl( - "imagesApiBaseUrl", - "GetBigThumbnail", - [{ originalImagePath: file.fileName }]) + '&rnd=' + Math.random(); + var thumbnailUrl = mediaHelper.getThumbnailFromPath(file.fileName); return thumbnailUrl; } @@ -186,12 +192,8 @@ }); var newVal = updateModelFromSelectedFiles(args.files); - - //need to explicity setDirty here to track changes - vm.fileUploadForm.$setDirty(); - //notify the callback - vm.onValueChanged({ value: newVal }); + notifyValueChanged(newVal); } angularHelper.safeApply($scope); 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 636437e387..9cdd4eeb03 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 @@ -307,11 +307,8 @@ function mediaHelper(umbRequestHelper) { var thumbnailUrl = umbRequestHelper.getApiUrl( "imagesApiBaseUrl", "GetBigThumbnail", - [{ originalImagePath: imagePath }]); - - //var ext = imagePath.substr(imagePath.lastIndexOf('.')); - //return imagePath.substr(0, imagePath.lastIndexOf('.')) + "_big-thumb" + ".jpg"; - + [{ originalImagePath: imagePath }]) + '&rnd=' + Math.random(); + return thumbnailUrl; }, diff --git a/src/Umbraco.Web.UI.Client/src/views/components/upload/umb-property-file-upload.html b/src/Umbraco.Web.UI.Client/src/views/components/upload/umb-property-file-upload.html index 6421525113..c22de15dae 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/upload/umb-property-file-upload.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/upload/umb-property-file-upload.html @@ -1,5 +1,6 @@ 
+
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 4e2d030190..cbc88ebacb 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 @@ -20,6 +20,11 @@ */ function valueChanged(value) { $scope.model.value = value; + + //if the value is empty, then tell the server to clear the files + if (!$scope.model.value) { + $scope.model.value = { clearFiles: true }; + } } }; diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/fileupload/fileupload.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/fileupload/fileupload.html index 9d36f593b4..44e6df2373 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/fileupload/fileupload.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/fileupload/fileupload.html @@ -1,6 +1,4 @@ 
-
{{model.value}}
- ( - controller => controller.GetBigThumbnail(0)) + controller => controller.GetBigThumbnail("")) }, { "sectionApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( diff --git a/src/Umbraco.Web/Editors/ContentControllerBase.cs b/src/Umbraco.Web/Editors/ContentControllerBase.cs index 164e1cfc62..13dd55c883 100644 --- a/src/Umbraco.Web/Editors/ContentControllerBase.cs +++ b/src/Umbraco.Web/Editors/ContentControllerBase.cs @@ -70,10 +70,12 @@ namespace Umbraco.Web.Editors // get the property var property = contentItem.PersistedContent.Properties[propertyDto.Alias]; + + // prepare files, if any matching property and culture + var files = contentItem.UploadedFiles + .Where(x => x.PropertyAlias == propertyDto.Alias && x.Culture == propertyDto.Culture) + .ToArray(); - //TODO: Need to update this API to support variants and/or basically any sort of 'key' - // prepare files, if any - var files = contentItem.UploadedFiles.Where(x => x.PropertyAlias == propertyDto.Alias).ToArray(); foreach (var file in files) file.FileName = file.FileName.ToSafeFileName(); diff --git a/src/Umbraco.Web/Editors/ImagesController.cs b/src/Umbraco.Web/Editors/ImagesController.cs index cdcade073e..a13e7d3a95 100644 --- a/src/Umbraco.Web/Editors/ImagesController.cs +++ b/src/Umbraco.Web/Editors/ImagesController.cs @@ -22,29 +22,6 @@ namespace Umbraco.Web.Editors _mediaFileSystem = mediaFileSystem; } - /// - /// 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); - - //fixme doesn't take into account variants - var imagePath = imageProp.GetValue().ToString(); - return GetBigThumbnail(imagePath); - } - /// /// Gets the big thumbnail image for the original image path /// @@ -60,30 +37,6 @@ namespace Umbraco.Web.Editors : 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); - - var imageProp = media.Properties[Constants.Conventions.Media.File]; - if (imageProp == null) - return new HttpResponseMessage(HttpStatusCode.NotFound); - - //fixme doesn't take into account variants - var imagePath = imageProp.GetValue().ToString(); - return GetResized(imagePath, width); - } - /// /// Gets a resized image for the image at the given path ///