Copied to clipboard

Flag this post as spam?

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


  • MartinB 411 posts 512 karma points
    Dec 10, 2010 @ 16:28
    MartinB
    0

    GetMedia New Schema - Images from static folder

    Hi there

    Been looking for a quick solution to this, but couldn't find any.

    I use the following XSLT to display header images from a folder, specified by a Media Picker property.

    What do i need to change in order to ditch the media picker and set a static folder id?

    I tried removing the media variable and setting the 1109 id in the getMedia call, but then nothing gets displayed? :/

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:variable name="media" select="$currentPage/bannerImage" />

    <xsl:template match="/">

    <xsl:variable name="mediaItems" select="umbraco.library:GetMedia($media, true())"/>

    <xsl:for-each select="$mediaItems/Image">
    <xsl:variable name="picFile" select="umbracoFile"/>
    <xsl:variable name="picW" select="umbracoWidth"/>
    <xsl:variable name="picH" select="umbracoHeight"/>
    <img>
    <xsl:attribute name="src"><xsl:value-of select="$picFile"/></xsl:attribute>
    </img>
    </xsl:for-each>

    </xsl:template>

    </xsl:stylesheet>

    Thanks in advance.

  • bob baty-barr 1180 posts 1294 karma points MVP
    Dec 10, 2010 @ 18:02
    bob baty-barr
    0

    you should be able to set the variable media = to your node id...

    <xsl:variable name="media" select="1109"/>

    <xsl:for-each select="umbraco.library:GetMedia($media,'true')/Image">

        <xsl:variable name="picFile" select="umbracoFile"/>
        <xsl:variable name="picW" select="umbracoWidth"/>
        <xsl:variable name="picH" select="umbracoHeight"/>
       
        <img>
            <xsl:attribute name="src"><xsl:value-of select="$picFile"/></xsl:attribute> 
        </img>
    </xsl:for-each>

    i think that should work...

  • MartinB 411 posts 512 karma points
    Dec 10, 2010 @ 22:15
    MartinB
    0

    I'm pretty sure i did just that, but i'll have to re-check.

    Thanks for helping out!

  • MartinB 411 posts 512 karma points
    Dec 13, 2010 @ 09:12
    MartinB
    0

    Hi Bob

    As i suspected it didn't work. I just get an empty space now. With <textarea>  i can see that i get the path and the bytesize following immediately, so i think the path needs to be seperated or?

  • Thijs Kuipers 43 posts 66 karma points
    Dec 13, 2010 @ 17:14
    Thijs Kuipers
    1

    Are you using <xsl:value-of/> to put the results in the textarea? That will only give you the textual contents of the results. Use <xsl:copy-of/> to copy the entire XML structure into the textarea.

    Bob Baty-Barr's reply is actually correct, although a bit verbose in using a variable.

  • MartinB 411 posts 512 karma points
    Dec 13, 2010 @ 22:29
    MartinB
    0

    Oh ok! I'll give it a go.

    I seriously need to pick up a book on xslt somewhere :-)

  • 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