Copied to clipboard

Flag this post as spam?

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


  • Mikael Axel Kleinwort 67 posts 310 karma points c-trib
    Feb 10, 2020 @ 19:43
    Mikael Axel Kleinwort
    0

    Umbraco 8.5.3: GetSrcSetUrls: cannot convert from ImageCropperValue to IPublishedContent

    I am starting to use Slimsy 3.0.0-beta3. I am on Umbraco 8.5.3.

    I am kind of copying the first Slimsy example on GitHub like so:

     <img src="@Url.GetCropUrl(Model.Hero, 323, 300, quality:30, furtherOptions:"&format=auto")"
                 data-srcset="@Url.GetSrcSetUrls(Model.Hero, 323, 300)"
                 data-src="@Url.GetCropUrl(Model.Hero, 323, 300)"
                 sizes="auto" class="lazyload" />
    

    The Hero property is an Image Cropper, as stated in the Slimsy example description. Excerpt from the modelbuilder generated file:

    [ImplementPropertyType("hero")]
    public Umbraco.Core.PropertyEditors.ValueConverters.ImageCropperValue Hero => this.Value<Umbraco.Core.PropertyEditors.ValueConverters.ImageCropperValue>("hero");
    

    yet, this expression:

    @Url.GetSrcSetUrls(Model.Hero, 323, 300)
    

    gives me this error:

    Error CS1503: Argument 2: cannot convert from 'Umbraco.Core.PropertyEditors.ValueConverters.ImageCropperValue' to 'Umbraco.Core.Models.PublishedContent.IPublishedContent'
    

    What am I missing? May be I am misunderstanding this sentence of the example description:

    Use this method for setting the crop dimensions in your Razor code, assumes your image cropper property alias is "umbracoFile"

    I don't know what that sentence means in relationship to the example.

    I am grateful for input - thank you!

  • Mikael Axel Kleinwort 67 posts 310 karma points c-trib
    Feb 11, 2020 @ 13:40
    Mikael Axel Kleinwort
    100

    Jeavon,

    I figured out my misunderstanding. I needed to use a MediaPicker on the docType, not an ImageCropper. Now it works. May be the Slimsy example description should be clarified. I will send you a PR.

    Also, thank you for your input on Our about how to use immage cropper with items in media (your answer here). With this information, I will be able to get it to work as intended. Very cool.

    Best regards! Mikael

Please Sign in or register to post replies

Write your reply to:

Draft