Can anyone point me in the direction of docs on ho...
# package-development
c
Can anyone point me in the direction of docs on how to handle an image property in a property editor's AngularJS controller (e.g., I've managed to find the image reference - but this can be either a legacy Media Picker image, or the MediaWithCrops thing). I can find just about ~> zero docs on how to get that from within the property editor's controller and do something with it there... If you know of any packages that does something with a mediapicker, I'd really like to know...
m
do you mean something like..
Copy code
javascript
  angular.module("umbraco").controller("SM.Blocks.LabelController", function ($scope, entityResource) {

    var vm = this;

    vm.imageUrl = null;
    vm.node = { icon: "icon-application-error color-red ", name: "n/a" };

    function loadImage(propertyValue) {
        if (propertyValue != undefined) {
            entityResource.getById(propertyValue, "Media").then(function (ent) {
                vm.imageUrl = ent.metaData.MediaPath;
            });
        } else {
            vm.imageUrl = null;
        }
    }

    function loadNode(propertyValue) {
        if (propertyValue != undefined) {
            entityResource.getById(propertyValue, "Document").then(function (ent) {
                vm.node = ent;
            });
        } else {
            vm.node = { icon: "icon-application-error color-red ", name: "n/a" };
        }
    }

    loadImage($scope.block.data.image);
    loadNode($scope.block.data.housetypeName);

    $scope.$watch("block.data.image", function (newValue, oldValue) {
        if (newValue === oldValue) return;
        loadImage(newValue);
    });

    $scope.$watch("block.data.housetypeName", function (newValue, oldValue) {
        if (newValue === oldValue) return;
        loadNode(newValue);
    });
});