Copied to clipboard

Flag this post as spam?

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


  • Nathan Rogan 22 posts 203 karma points
    Feb 12, 2021 @ 15:38
    Nathan Rogan
    0

    Change crop mode in custom block list view

    I have created a custom view for a block list. I'm trying to change the default "Pad" crop mode to "Crop" but getting the error ReferenceError: Crop is not defined

    Has anyone got any ideas to fix this?

    angular.module("umbraco").controller("blockCustomHero", function ($scope, mediaResource, imageUrlGeneratorResource ) {
    var imageUdi = $scope.block.data.hero;
    mediaResource.getById(imageUdi)
        .then(function (media) {
            imageUrlGeneratorResource.getCropUrl(media.mediaLink, 1280, 250, Crop ).then(function (cropUrl) {
                console.log(cropUrl);
                $scope.imageUrl = cropUrl;
            });
        });
    

    });

    Thanks

  • Marc Goodson 2157 posts 14434 karma points MVP 9x c-trib
    Feb 21, 2021 @ 10:08
    Marc Goodson
    100

    Hi Nathan

    https://github.com/umbraco/Umbraco-CMS/blob/34e80d86e8c0b754f6b7a02e307f53cb32806bbe/src/Umbraco.Web.UI.Client/src/common/resources/imageurlgenerator.resource.js

    I think it's expecting the CropMode to be specified as a string...

    So would:

     imageUrlGeneratorResource.getCropUrl(media.mediaLink, 1280, 250, "Crop" ).then(function (cropUrl) {
    

    work for you?

    regards

    Marc

  • Nathan Rogan 22 posts 203 karma points
    Feb 21, 2021 @ 23:29
    Nathan Rogan
    0

    Thanks Marc, that's worked great

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies