Copied to clipboard

Flag this post as spam?

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


  • Ondřej Kobza 10 posts 90 karma points
    Oct 08, 2019 @ 22:39
    Ondřej Kobza
    0

    How to get url from the image cropper

    Hello guys.. I'm trying to figure out how to get the URL of the uploaded image from the image cropper (not any of the pre-made crops, but the whole image) in Razor.

    I've been using this:

    @Model.Value("image")
    

    When I use this with the @ symbol inside of an HTML tag, it returns just the URL. That works fine for me.

    BUT when I use this inside of a block of code and try to assign it to a variable, it returns a lot of other stuff with it (focal points, all the crops and so on)..

    I absolutely don't understand what's going on and why. How can I SIMPLY get a URL of an image.

    This is what I'm trying to do:

     if (@Model.TemplateId == 1167)
     {
        imageUrl = String.Format("{0}?width=1280&height=640&mode=pad", Model.Value("image"));
     }
    

    I don't have the models builder setup and I'm using Umbraco 8.1.2

  • Shaishav Karnani from digitallymedia.com 330 posts 1562 karma points
    Oct 09, 2019 @ 06:43
    Shaishav Karnani from digitallymedia.com
    0

    Hi,

    Please can you try.

    imageUrl = String.Format("{0}?width=1280&height=640&mode=pad", Model.Value<iPublishedContent>("image").Url);
    

    Hope this helps to solve the issue.

    Cheers,

    Shaishav

  • Ondřej Kobza 10 posts 90 karma points
    Oct 09, 2019 @ 12:06
    Ondřej Kobza
    0

    With this code I get an error:

    The type or namespace name 'iPublishedContent' could not be found (are you missing a using directive or an assembly reference?)

  • Ondřej Kobza 10 posts 90 karma points
    Oct 09, 2019 @ 21:31
    Ondřej Kobza
    0

    This cool guy helped me in a Facebook group, so I have a solution.

    using Umbraco.Core.PropertyEditors.ValueConverters
    
    imageCropUrl = String.Format("{0}?width=1280&height=640&mode=pad", Model.Value<ImageCropperValue>("image").Src);
    
Please Sign in or register to post replies

Write your reply to:

Draft