Copied to clipboard

Flag this post as spam?

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


  • LearningUmbraco 8 posts 78 karma points
    May 17, 2016 @ 18:09
    LearningUmbraco
    0

    Get URL of the image in Media folder

    I am using Umbraco web forms and using XSLT with it. I have a template where user can select image from the media folder and I want to show that image on the website. I am using the following code to get the URL of the image in XSLT:

    I am using "umbracoFile" to get the image URL but its not returning me the URL exaclty but its returning the string "{src: '/media/1002/william1.jpg', crops: []}". and which is why image is not showing up on the page. Anybody know how can I just get the link (i.e. ../media/1002/william1.jpg) so that I can put it in the src.

  • LearningUmbraco 8 posts 78 karma points
    May 17, 2016 @ 18:10
    LearningUmbraco
    0

    Sorry, I dont know why code was not posted before.

    <xsl:variable name="userImagesVariable" select="userImage"/>
        <xsl:if test="string($userImagesVariable)!=''">
            <xsl:variable name="images" select="$userImagesVariable"/>
            <xsl:variable name="mediaItems" select="umbraco.library:GetMedia($images, false())"/>
            <xsl:if test="$mediaItems">
                <img src="{$mediaItems/umbracoFile}" alt="{$mediaItems/altText}" />
            </xsl:if> 
      </xsl:if>
    
  • LearningUmbraco 8 posts 78 karma points
    May 17, 2016 @ 18:48
    LearningUmbraco
    0

    I solved the problem using substring before and after but will be really good to know if there is a better way to do it. Thanks.

Please Sign in or register to post replies

Write your reply to:

Draft