Copied to clipboard

Flag this post as spam?

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


  • Christopher Thrower 20 posts 60 karma points
    Aug 10, 2020 @ 22:29
    Christopher Thrower
    0

    Image cropper not returning path in master.cshtml

    I'm trying to get the src for an image cropper object within my Master template file, to use in a tag.

    For some reason, @Model.Value("thumbnail") returns the URL no problem. However, when I add another string to it, for example: @(url + Model.Value("thumbnail") it appears to just render a string of the whole cropper object (See image).

    enter image description here

    I have tried a bunch of various things, but it's been so long since I've worked with Umbraco I'm failing massively!

  • Owain Williams 482 posts 1414 karma points MVP 7x c-trib
    Aug 11, 2020 @ 07:35
    Owain Williams
    0

    Hey Christopher, What I would be tempted to do is something like this:

    var mediaThumbnail = @Model.Value("thumbnail");
    

    then you join the two together

    @(url + mediaThumbnail);
    

    What does that give you?

    Are you able to share more of your code at all to allow us to help a bit more?

    Cheers,

  • Christopher Thrower 20 posts 60 karma points
    Aug 11, 2020 @ 08:23
    Christopher Thrower
    0

    Hey Owain,

    I tried similar last night and ended up with pretty much the same as this just after posting this thread and it still seems to return the same.

    var url = "https://www.yourtravelpa.co.uk";
    var image = Model.Value("thumbnail");
    

    Then, I am using it like this:

    <meta property="og:image" content="@(url + image)" />
    

    And it returns the following:

    <meta property="og:image" content="https://www.yourtravelpa.co.uk{&quot;src&quot;:&quot;/media/n4klvmaa/travel-planning.jpg&quot;,&quot;focalPoint&quot;:{&quot;left&quot;:0.5,&quot;top&quot;:0.5},&quot;crops&quot;:[{&quot;alias&quot;:&quot;Thumbnail&quot;,&quot;width&quot;:570,&quot;height&quot;:420,&quot;coordinates&quot;:null}]}" />
    
  • Owain Williams 482 posts 1414 karma points MVP 7x c-trib
    Aug 11, 2020 @ 08:29
    Owain Williams
    0

    Ah! So, with the imagecropper you are probably best checking out : https://our.umbraco.com/documentation/getting-started/Backoffice/Property-Editors/Built-in-Property-Editors/Image-Cropper/

    You can .getGropUrl which should give you the url rather than the string that you are currently getting.

  • Christopher Thrower 20 posts 60 karma points
    Aug 11, 2020 @ 08:41
    Christopher Thrower
    0

    Hi,

    Thanks again, I've tried a bunch of different ways, nothing seems to work for me :(

    Test #1: var image1 = Model.Value("thumbnail").GetCropUrl(); Results in:

    object' does not contain a definition for 'GetCropUrl'
    

    Test #2:

    var image2 = Url.GetCropUrl(Model.Thumbnail, "thumbnail");
    

    Results in:

    IPublishedContent' does not contain a definition for 'Thumbnail' and no accessible extension method 'Thumbnail'
    

    Test #3:

    var image3 = Model.Thumbnail.GetCropUrl("thumbnail");
    

    Results:

    IPublishedContent' does not contain a definition for 'Thumbnail' and no accessible extension method 'Thumbnail'
    

    Test#4

    var image4 = Url.GetCropUrl(Model.Value("thumbnail"), "thumbnail");
    

    Results:

    UrlHelper' does not contain a definition for 'GetCropUrl' and the best extension method overload 'ImageCropperTemplateExtensions
    
  • Owain Williams 482 posts 1414 karma points MVP 7x c-trib
    Aug 11, 2020 @ 08:55
    Owain Williams
    0

    Hey Christopher, What property picker are you using in the backoffice for picking the image?

    O.

  • Christopher Thrower 20 posts 60 karma points
    Aug 11, 2020 @ 09:05
    Christopher Thrower
    0

    Hi,

    It's using the ImageCropper property

  • Owain Williams 482 posts 1414 karma points MVP 7x c-trib
    Aug 11, 2020 @ 09:19
    Owain Williams
    0

    Rather than Model.Thumbnail.GetCropUrl("thumbnail") go for Model.Image.GetCropUrl("thumbnail")

  • Christopher Thrower 20 posts 60 karma points
    Aug 11, 2020 @ 09:21
    Christopher Thrower
    0

    Hey,

    That returns:

    'IPublishedContent' does not contain a definition for 'Image' and no accessible extension method 'Image'
    
  • Owain Williams 482 posts 1414 karma points MVP 7x c-trib
    Aug 11, 2020 @ 09:22
    Owain Williams
    0

    Are you able to do a screenshare? I'd be happy to have a look that way, might be easier.

    O.

  • Christopher Thrower 20 posts 60 karma points
    Aug 11, 2020 @ 09:32
    Christopher Thrower
    0

    Hey,

    That would be great. I'm in my day job at the moment though. I can do one this evening if you are free? (Around 8:30pm UK time)

    Either that, or I can set you up with an Umbraco user login for my site?

    Thanks for your help :-)

  • Owain Williams 482 posts 1414 karma points MVP 7x c-trib
    Aug 11, 2020 @ 09:34
    Owain Williams
    0

    Cool. Drop me an email - * or if you are on Slack http://umbracians.chat/ give me a shout.

    If you add me to your project, I can probably have a look today. I'm doing a talk at a meetup tonight.

  • Owain Williams 482 posts 1414 karma points MVP 7x c-trib
    Aug 11, 2020 @ 13:06
    Owain Williams
    100

    If anyone else stumbles across this - the issue seems to be an early Umbraco 8 version bug.

    https://github.com/umbraco/Umbraco-CMS/issues/5737

    Hopefully a CMS upgrade will fix things :)

    O.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies