Copied to clipboard

Flag this post as spam?

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


  • Sean Håkansson 67 posts 193 karma points
    Jun 30, 2023 @ 12:15
    Sean HÃ¥kansson
    0

    Media Picker Focal point not used

    Hi, im running version 11 and I'm having an issue where my focal point is only read from the media directly and not my local focal point from my media picker.

    @Model.Content.Image.GetCropUrl( width: 2560, height:800, preferFocalPoint:true, quality:75)
    

    I have tried calling LocalCrops.GetCropUrl, but this helper requires me to use an alias (or a ImageUrlGenerator, but this gives me blank string). I only want to use custom defined width and height and respect the local focal point.

    @(Model.Content.Image.LocalCrops.GetCropUrl(width: 576, height: 800, ImageUrlGenerator))
    

    Seems like I'm missing something very simple, but not much info in the documentation about the cropper without aliases.

    Thanks

  • Jim Gettrup 7 posts 48 karma points
    Mar 13, 2024 @ 11:49
    Jim Gettrup
    0

    I've been having similar problems trying to use a local focal point and a custom width and height, but without a custom crop.

    I finally managed to get what I wanted using this in the view:

    <img src="@Url.GetCropUrl(item.Image.LocalCrops, null, width: 800, height: 800, quality: 75)">

    This is using one of the GetCropUrl extension methods on the Url helper object (rather than directly on the model's property). You may need "@using Umbraco.Extensions" in your view.

    You need to pass in an ImageCropperValue as the first parameter, which I eventually found in the LocalCrops property of my Image object. "Image" is a MediaWithCrops object coming from a MediaPicker3 property.

    You also have to pass in a crop alias, but since I hadn't defined any I just tried passing in "null" and it worked!

    It doesn't seem to matter what the value of "preferFocalPoint" is, so I left that out. I've yet to discover what that parameter is meant to do, but maybe it's only relevant if you're using a crop alias?

    There seem to be so many (too many?) different ways to get a URL out of a MediaPicker3, and some of them are not covered in the documentation. I suppose that property editor is trying to do a lot of different things, but it would be useful to have more advice in the docs on all the different possibilities.

    I'm using Umbraco 10.8.2, but hopefully this will work for you too.

Please Sign in or register to post replies

Write your reply to:

Draft