Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • John Churchley 272 posts 1258 karma points c-trib
    Jul 14, 2015 @ 10:40
    John Churchley
    0

    Displaying Cropped Images in Backoffice

    Hi,

    Firstly I've changed the image media type umbracoFile property to of type Image Cropper so all my images have a choice of 4 different crops.

    The user selects the Image size before the selecting the image is possible. So I know what size of image they are requesting. I'm now trying to get the cropped image to display in the backend.

    In the Render View i was able to do this

    @Umbraco.Media(Model.value.mediaId.ToString()).GetCropUrl("w" + Model.value.mediaWidth + "xh" + Model.value.mediaHeight)
    

    I'm trying to replicate a similar thing for the content editor (backend)

     <img src="{{ control.value.mediaThumbnail }}"  />
    

    Controller method when adding image

      $scope.addMedia = function () {
                dialogService.mediaPicker({
                    multiPicker: false,
                    startNodeId: $scope.model.config.mediaStartNode,
    
                    callback: function (data) {
    
                        //it's only a single selector, so make it into an array
                        if (!false) {
                            data = [data];
                        }
    
                        _.each(data, function (media) {
                            $scope.control.value.mediaId = media.id;
                            $scope.control.value.mediaSrc = media.image;
                            $scope.control.value.mediaThumbnail = media.thumbnail 
                        });
                    }
                });
                dialogService.close();
            };
    
Please Sign in or register to post replies

Write your reply to:

Draft