Copied to clipboard

Flag this post as spam?

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


  • WURMi 4 posts 74 karma points
    Mar 25, 2017 @ 22:48
    WURMi
    0

    GetCropUrl with imageCropMode

    Hello,

    I'm using Umbraco version 7.5.9 and I have some difficulties using predefined crops with crop mode other than "Crop". I'd like to use predefined crop size with crop mode "Max".

    Let me write some samples:

    @mediaItem.GetCropUrl(cropAlias: "thumb_landscape", useCropDimensions: true)
    

    this work and return string is:

    /media/1115/u300981_medium.jpg?anchor=center&mode=crop&width=160&height=90&rnd=131349260720000000

    @mediaItem.GetCropUrl(cropAlias: "thumb_landscape", useCropDimensions: true, quality: 50)
    

    if I add some custom attributes like 'quality', it work as well:

    /media/1115/u300981_medium.jpg?anchor=center&mode=crop&quality=50&width=160&height=90&rnd=131349260720000000

    @mediaItem.GetCropUrl(cropAlias: "thumb_landscape", useCropDimensions: true, quality: 50, imageCropMode: ImageCropMode.Max)
    

    but why if I add imageCropMode with something other than 'Crop' width and height attributes disappears???

    /media/1115/u300981_medium.jpg?mode=max&quality=50&rnd=131349260720000000

    I spend couple of hours trying to understand if this is a some special feature or bug, but more and more I think it's a bug ;-/

    Thanks,

    Marek

  • Dan Diplo 1297 posts 4816 karma points MVP 2x c-trib
    Mar 27, 2017 @ 18:53
    Dan Diplo
    0

    The Umbraco image cropper actually utilises Image Processor in the background - the docs for resize modes are here - http://imageprocessor.org/imageprocessor-web/imageprocessingmodule/resize/

    Many of the crop modes keep the image's aspect ratio and only change the dimension of either height OR width, so it doesn't make sense to specify the exact size for both - they are dynamically calculated at runtime.

  • Sven Geusens 131 posts 698 karma points c-trib
    Mar 28, 2017 @ 08:05
    Sven Geusens
    0

    But if you look at the max documentation, you will see you can specify both, so WURMi seems to be right to assume that there is a bug using the cropalias together with something else than crop

    Resize Max

    Resizes the image to the given dimensions. If the set dimensions do not match the aspect ratio of the original image then the output is resized to the maximum possible value in each direction while aintaining the original aspect ratio.

    http://your-image?width=500&height=500&mode=max

  • WURMi 4 posts 74 karma points
    Mar 28, 2017 @ 08:27
    WURMi
    0

    You're right Sven. This is exactly what I need to achieve. Using both dimensions (defined in crop alias) together with crop mode Resize Max

  • Sven Geusens 131 posts 698 karma points c-trib
    Mar 28, 2017 @ 11:57
    Sven Geusens
    0

    What happens if you put the height and width parameters in the generated url? Do you get the image in the correct format then? If so, maybe make a bug/feature report on the issue tracker

  • WURMi 4 posts 74 karma points
    Mar 28, 2017 @ 12:36
    WURMi
    0

    Yes, it work like described in documentation => the image is resized to the maximum possible dimensions in consideration of aspect ratio. So I will create a bug report on the issue tracker. Thanks for confirmation of my assumption ;)

  • Perry Cope 3 posts 93 karma points
    1 week ago
    Perry Cope
    0

    I know this is old but was this ever fixed Im still seeing the same issue and googling only ever brings up this question.

Please Sign in or register to post replies

Write your reply to:

Draft