Copied to clipboard

Flag this post as spam?

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


  • Billy 55 posts 266 karma points c-trib
    Dec 29, 2020 @ 10:54
    Billy
    0

    Trying to figure out media picker, cropper, and autorotate parameter

    Hello,

    Testing out the media picker and image cropper in a basic example. In my example, I'm using an image with EXIF version 0221.

    I have a document type 'Example' with an Umbraco.MediaPicker and an Umbraco.MediaCropper.

    enter image description here

    The content looks like this:

    enter image description here

    Printing the Umbraco.MediaPicker with this code:

    @if (example.SingleImagePicker != null)
                {
                    <div>
                        <h2>Single Image Picker</h2>
                        <img src="@Url.GetCropUrl(example.SingleImagePicker)" alt="" style="width:200px;" />
                        <img src="@Url.GetCropUrl(example.SingleImagePicker, 100, 200)" alt="" />
                        <img src="@Url.GetCropUrl(example.SingleImagePicker, 100, 200, "umbracoFile", null, null, null, null, false, false, true, "&autorotate=true", null, true, true)" alt="" />
                    </div>
                }
    

    This gives following result:

    enter image description here

    The first image is the default without any extra parameters. This looks fine. For the second image I pass a width & height. This gives the correct aspect ratio but the image is rotated. In the third image I pass "&autorotate=true", which rotates my image correctly but breaks the aspect ratio.

    Then there is the Umbraco.MediaCropper:

    @if (example.CroppedImagePicker != null)
                {
                    <div>
                        <h2>Cropped Image Picker</h2>
                        <img src="@example.GetCropUrl("croppedImagePicker", "square")" alt="" />
                        <img src="@example.GetCropUrl("croppedImagePicker", "landscape")" alt="" />
                        <img src="@example.GetCropUrl("croppedImagePicker", "portrait")" alt="" />
                        <img src="@Url.GetCropUrl(example.CroppedImagePicker, null, null, "square", null, null, null, false, false, null, null, null, true, true)" alt="" />
                    </div>
                }
    

    Gives following result:

    enter image description here

    The first 3 images give the correct crops, but are not rotated. The 4th image I tried a different way but this does not give my crop. It just gives the original image.

    How can I get the correct aspect ratio and image rotation with the Umbraco.MediaPicker? And how do I pass the rotation for the cropper?

    Thanks for any help!

Please Sign in or register to post replies

Write your reply to:

Draft