Copied to clipboard

Flag this post as spam?

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


  • Steve 472 posts 1216 karma points
    Jan 20, 2016 @ 16:50
    Steve
    0

    GetMedia Not pulling Image Every Time

    I have an XSLT carousel that pulls an image from a property (featuredImage) of a newsArticle document type. Sometimes I am noticing, that I get the "Hello World" image instead. What could be causing this? Here is my xslt that gets the image from the Media Library:

    <img src="/ImageGen.ashx?image={umbraco.library:GetMedia(featuredImage, 1)/umbracoFile}&amp;height=325" />
    
  • Steve 472 posts 1216 karma points
    Jan 21, 2016 @ 13:37
    Steve
    0

    I've tried using

    umbraco.library:GetMedia($currentPage/featuredImage, 1)/umbracoFile
    

    since I am using a Media Picker to select "featuredImage", but the script won't save. I am using Umbraco 6.1 and webforms.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jan 21, 2016 @ 13:53
    Dennis Aaen
    1

    Hi Steve,

    Maybe you need to ensure that the user has picked a image in the media picker.

    Could you please try this piece of code, and see how it goes.

    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/featuredImage, 0)" />
    
     <xsl:if test="$media">
        <xsl:variable name="url" select="$media/umbracoFile" />
            <img>
                <xsl:attribute name="src">
                    <xsl:text>/ImageGen.ashx?image=</xsl:text>
                    <xsl:value-of select="$media"/>
                    <xsl:text>&amp;height=325</xsl:text>
                </xsl:attribute>
            </img>
     </xsl:if>
    

    Hope this helps,

    /Dennis

  • Steve 472 posts 1216 karma points
    Jan 21, 2016 @ 14:23
    Steve
    100

    Thanks Dennis! Your code works if you change this:

        <xsl:if test="$media">
            <xsl:variable name="url" select="$media/umbracoFile" />
            <img>
            <xsl:attribute name="src">
                <xsl:text>/ImageGen.ashx?image=</xsl:text>
                <xsl:value-of select="$url" />
                <xsl:text>&amp;height=325</xsl:text>
                </xsl:attribute>
            </img>
        </xsl:if>
    

    Thanks again!

  • Steve 472 posts 1216 karma points
    Jan 21, 2016 @ 14:31
    Steve
    0

    Ahh, I think you meant to set the value-of select within the attribute to "$url".

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jan 21, 2016 @ 15:11
    Dennis Aaen
    0

    Hi Steve,

    Yes of course a small mistake by me.

    The most important, thing here is that you resolve the issue, and get it working.

    /Dennis

  • Steve 472 posts 1216 karma points
    Jan 21, 2016 @ 15:12
    Steve
    0

    Thanks for your help Dennis!

Please Sign in or register to post replies

Write your reply to:

Draft