Copied to clipboard

Flag this post as spam?

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


  • Robert Leet 7 posts 77 karma points
    Apr 29, 2016 @ 17:46
    Robert Leet
    0

    umbracofile img src html not well formed

    Hello, I am trying to use the NivoSlider but when the view tries to fill in the src tag of the image with a call to umbracofile it is getting populated with this:

    src='{ "src": "/media/1038/slide2.jpg", "focalPoint": { "left": 0.48785425101214575, "top": 0.49685534591194969 } }'

    which breaks the image display.

    the call is src='@image.GetPropertyValue("UmbracoFile")'

    I would go directly to the URL if I knew how but I'm not sure how to see what properties can be used with the default media object.

    any help would be appreciated.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 30, 2016 @ 06:39
    Jan Skovgaard
    0

    Hi Robert and welcome to our :)

    Hmm when you mention NivoSlider are you then doing your own implementation of it ore are you basing it on the package here https://our.umbraco.org/projects/website-utilities/nivoslider-for-umbraco/ ? I'm not sure whether this package still works since it's 5 years old and made in a time where Umbraco 4 was new...However it might be an evergreen package that just works no matter how much changes in Umbraco.

    The first code part is that the rendered code you see when viewing your website?

    Perhaps it would be easier to figure out if you posted a code sample where you call the @image.GetPropertyValue("UmbracoFile") to figure out where things go wrong - I suspect it's because underlying API to fetch the content has changed since the NivoSlider package was made (If that is what you're using).

    Looking forward to hearing more from you.

    /Jan

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Apr 30, 2016 @ 19:32
    Sebastiaan Janssen
    0

    This should fix it: src='@image.GetCropUrl("UmbracoFile")'

  • Robert Leet 7 posts 77 karma points
    May 02, 2016 @ 16:35
    Robert Leet
    0

    Thank you Jan and Sebastiaan, I am using a newer version found here:

    https://our.umbraco.org/projects/website-utilities/slider

    Sebastiaan your solution looks good but its not working. here is how the variable image is created:

    var image = slide.MediaById(imageID);

    I get error loading partial view script when i use src='@image.GetCropUrl("UmbracoFile")'

    Can either of you point me to a document that maps out all of the API calls available in Umbraco? Unfortunately i am not getting a lot of intellisense support with .cshtml pages. I have tried both visual studios 2013 and web matrix. I am new to razor code by the way. Thank you for your responses.

  • Robert Leet 7 posts 77 karma points
    May 02, 2016 @ 18:13
    Robert Leet
    0

    just wanted to let you know that i found a way to make

    var file = mediaItem.umbracoFile.src

    and i think I could apply GetCropUrl in a similar way if need be. The code was causing errors inline so i pulled it out to a code block and just used the variable file inline. Thanks for your help with this.

Please Sign in or register to post replies

Write your reply to:

Draft