Copied to clipboard

Flag this post as spam?

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


  • J 447 posts 864 karma points
    Feb 27, 2018 @ 17:04
    J
    0

    Help with getting image from media

    Using version 7.5 (if i recall correctly) of Umbraco. I have some XSLT which im trying to configure to get the image that was selected when the page was published.

    Here is my code

    <xsl:variable name="ImageSelection" select="umbraco.library:GetMedia(UserImage, 0)" />
    
    <xsl:variable name="MyData" select="umbraco.library:JsonToXml($ImageSelection/umbracoFile)" />
    
    <img src="{$MyData}" width="100" height="200"  />
    

    Now which ever way i do this im getting a range of errors i.e, value was too large or small for int32 or the src value is empty (when i view in page source) but if i hard code a value (to test that a value is being pulled across) then i do see it.

    UserImage - is the field name in my doc type which has a media picker attached to it so the user can select an image.

    Appreciate any help on this.

  • Søren Tidmand 129 posts 366 karma points
    Mar 05, 2018 @ 16:35
    Søren Tidmand
    100

    Hi J,

    I think that you might find the solution in this previous post:

    https://our.umbraco.org/forum/developers/xslt/75621-xslt-getmediaumbracofile-returns-new-schema#comment-241917

    As I can see it you need to specify /src in the img-tag:

    <img src="{$MyData/src}" width="100" height="200"  />
    

    /Søren

Please Sign in or register to post replies

Write your reply to:

Draft