How to get hold of the crop when using local crops...
# help-with-umbraco
c
V13.6.0 Using Slimsy I need to put the crop name in. But, I don't know what it is because this image picker is using local crops and the editor can choose from a few. So, how do you get hold of the selected crop name?
Copy code
@if (Model.Content.BannerImage is MediaWithCrops theImage && !isBackoffice) {
<slimsy-picture media-item="@theImage" css-class="lazyload img-fluid" crop-alias="@theImage.LocalCrops.GetCrop("????????")" render-lqip="true" alt-text="@Model.Content.Title" size="auto"></slimsy-picture>
}
Thanks
d
Are the crops all in the same image record?
m
Hey Craig, how are you getting the user to select a crop?
c
As far as I know they are. I'm not doing anything fancy.
I added the crops to the media picker. So the editors just click on the image they've selected and it then show in a flyout panel with the two crops showing the images right hand side. They just click on one to select it. There's no instructions I can find that tell you how to find what's been selected.
d
How did you add the crops to the media picker?
m
Does that retain the highlighted crop when you return to the item? I had understood it that the crop highlighting was to allow the user to adjust or select a different center point crop to crop. I don't think there is a way of selecting a crop for the frontend to use
c
Well you can add more than one crop to the picker, so it seems a bit pointless if you can't.
It's on the bottom of the picker if you edit it when you add it to the docType. See the Type Definition Example... https://docs.umbraco.com/umbraco-cms/13.latest/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/media-picker-3#using-crops
1st time I've used local crops tbh
m
It's all about defining local crops rather than picking local crops. The idea being you may define general crops in the media section, but for a particular page you want a different part of the image selected as your crop. Local crops is the mechanism for making crops context specific rather than global. HTH
c
Ok, well it's all good learning. I'll re-engineer it. Thanks.
m
You could use what you have to define the local crops and then have another picker (drop down or possibly a contentment picker) to allow the user to select a crop to use
4 Views