I've created a special controller for an image cropping tool that pops up over a media item in the content section. Right now I can manipulate the crops in the overlay, but when I click "Save Crops", the changes don't stick. However, if I use the image cropper in the media section, everything works as expected.
I tried following the guidelines in the documentation to save the changes using the media resource:
mediaResource.getById(1234)
.then(function(media) {
media.name = "I want a new name!";
mediaResource.save(media, false)
.then(function(media){
alert("Retrieved, updated and saved again");
});
});
In my overlay object, I have a submit function that is triggered when the user clicks on the "Save Crops" button:
submit: function (model) { //when user clicks save crops button
$scope.overlay.saving = true;
mediaResource.getById($scope.images[0].udi)
.then(function (media) {
media.umbracoFile = $scope.overlay.value;
mediaResource.save(media, false, []).then(function (media) { //save changes to media item, or create if new
console.log("On saving start end:", $scope);
$scope.overlay.saving = false;
$scope.overlay.show = false;
notificationsService.remove(0);
notificationsService.success("The crops for '" + media.name + "' have been saved");
});
});
}
When I click on "Save Crops," which calls the submit function, I don't receive any error messages, but the changes are not actually saved. I'm confused about what steps to take with the media object to ensure my modifications are properly saved.