Copied to clipboard

Flag this post as spam?

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


  • Mikael Mørup 297 posts 326 karma points
    Aug 17, 2009 @ 14:29
    Mikael Mørup
    0

    Problem wit inserting image

    I have an xslt fiel with the following XSLT inspired from a recent thread.

    Somehow it dosent insert the picture as i expect.

    I have boiled it down to the choose statement. I doesent seem to get the property from the page (Property named billede, is a mediapicker)

     

     

    <?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" xmlns:umbsql="urn:umbsql" xmlns:myExt="urn:myExt"
        exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets umbsql myExt ">


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

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <!-- start writing XSLT -->
    <xsl:variable name="picID">
              <xsl:choose>
               <xsl:when test="data[@alias='billede'] != ''"><xsl:value-of select="data[@alias='billede']" /></xsl:when>
               <xsl:otherwise>2138</xsl:otherwise>
              </xsl:choose>
    </xsl:variable>

    <xsl:if test="$picID != '' ">

        <img>
            <xsl:attribute name="src">
                <xsl:value-of select="umbraco.library:GetMedia($picID, false)/data [@alias = 'umbracoFile']" />
                </xsl:attribute>
        </img>
    </xsl:if>

    </xsl:template>

    </xsl:stylesheet>

     

     

    i tried to use string(data[@alias='billede'])  but that doesent change anything. I doublechecked spelling of property names and also checked that a picture is actually selected with the media picker, but still no go.

    I have a feeleing that i'm overlooking some stupid mistake.

     

    Mikael

  • Douglas Robar 3570 posts 4671 karma points MVP ∞ admin c-trib
    Aug 17, 2009 @ 14:33
    Douglas Robar
    0

    What is the result from <xsl:value-of select="data[@alias='billede']" />

    It seems like it doesn't contain what you're expecting. So what does it contain? Is it just a number (the media id), or more than that? Or is it empty?

    cheers,
    doug.

  • Mikael Mørup 297 posts 326 karma points
    Aug 17, 2009 @ 14:38
    Mikael Mørup
    0

    Hi Dough.

    It's empty

     

     

  • Mikael Mørup 297 posts 326 karma points
    Aug 17, 2009 @ 14:46
    Mikael Mørup
    0

    Hmm

    It probably has nothing to do with most of the above XSLT.

    This:

    <xsl:value-of select="string(data[@alias='billede'])" />

    doesent even work alone,  so somehow the mediapicker property is empty.

     

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Aug 17, 2009 @ 14:47
    Peter Dijksterhuis
    100

    Try:

    <xsl:value-of select="$currentPage/data[@alias='billede']" />

  • Mikael Mørup 297 posts 326 karma points
    Aug 17, 2009 @ 15:07
    Mikael Mørup
    0

    Thanks Peter

    A combination of your code and a refresh of the cash solved the problem.

    It's still a bit strange, i tried to change the datatype of the property to a contentpicker, expecting to se just a node id, but that didn't work either.

    anyways now it works

    You guys rock :-)

    Mikael

  • 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