Skip to content

Commit

Permalink
Add images in grid - fixes 9982 (#9987)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastiaan Janssen <sebastiaan@umbraco.com>
  • Loading branch information
nathanwoulfe and nul800sebastiaan authored Mar 17, 2021
1 parent 156c1c9 commit e201977
Showing 1 changed file with 16 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
angular.module("umbraco")
.controller("Umbraco.PropertyEditors.Grid.MediaController",
function ($scope, userService, editorService, localizationService) {
$scope.thumbnailUrl = getThumbnailUrl();
function ($scope, userService, editorService, localizationService) {

$scope.thumbnailUrl = getThumbnailUrl();

if (!$scope.model.config.startNodeId) {
if ($scope.model.config.ignoreUserStartNodes === true) {
$scope.model.config.startNodeId = -1;
Expand All @@ -29,16 +29,16 @@ angular.module("umbraco")
onlyImages: true,
dataTypeKey: $scope.model.dataTypeKey,
submit: model => {
updateControlValue(model.selection[0]);
updateControlValue(model.selection[0]);
editorService.close();
},
close: () => editorService.close()
close: () => editorService.close()
};

editorService.mediaPicker(mediaPicker);
};

$scope.editImage = function() {
$scope.editImage = function() {

const mediaCropDetailsConfig = {
size: 'small',
Expand All @@ -47,17 +47,17 @@ angular.module("umbraco")
updateControlValue(model.target);
editorService.close();
},
close: () => editorService.close()
close: () => editorService.close()
};

localizationService.localize('defaultdialogs_editSelectedMedia').then(value => {
mediaCropDetailsConfig.title = value;
editorService.mediaCropDetails(mediaCropDetailsConfig);
});
});
}

/**
*
*
*/
function getThumbnailUrl() {

Expand Down Expand Up @@ -94,19 +94,15 @@ angular.module("umbraco")

return url;
}

return null;
}

/**
*
* @param {object} selectedImage
*
* @param {object} selectedImage
*/
function updateControlValue(selectedImage) {

const doGetThumbnail = $scope.control.value.focalPoint !== selectedImage.focalPoint
|| $scope.control.value.image !== selectedImage.image;

// we could apply selectedImage directly to $scope.control.value,
// but this allows excluding fields in future if needed
$scope.control.value = {
Expand All @@ -118,10 +114,6 @@ angular.module("umbraco")
caption: selectedImage.caption,
altText: selectedImage.altText
};


if (doGetThumbnail) {
$scope.thumbnailUrl = getThumbnailUrl();
}
}
$scope.thumbnailUrl = getThumbnailUrl();
}
});

0 comments on commit e201977

Please sign in to comment.