Copied to clipboard

Flag this post as spam?

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


  • TaoistTotty 246 posts 314 karma points
    May 23, 2011 @ 14:51
    TaoistTotty
    0

    Image from XSLT

    I have just tried adding the following XSLT, and no image or anything is shown.

    What have I missed?

    <?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:template match="/">
      <xsl:value-of select="$currentPage/sideImage"/>
      <xsl:variable name="test" select="$currentPage/sideImage"/>
      <xsl:variable name="image" select="umbraco.library:GetMedia($test, 'false')"/>
      <xsl:value-of select="$test"/>
      <img src="{$image/umbracoFile}"/>
      


    </xsl:template>

    </xsl:stylesheet>

    The two value-of's show the node ID, but nothing is shown as soon as the GetMedia is done.

    Have just upgraded a site from 4.0.3 to 4.5.2.

    Many thanks

    TT

  • Fuji Kusaka 2203 posts 4220 karma points
    May 23, 2011 @ 15:01
    Fuji Kusaka
    0

    Taoist try using the img attibute

     

    <img src="{img}" alt="{@nodeName}" width="" height="" /> 
  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    May 23, 2011 @ 15:05
    Dennis Aaen
    0

    Hi Taoist

    Maybe you could try something like this.

    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/imageAlias, 0)" />

    <xsl:if test="$media!=''">
           
    <img src="{$media/umbracoFile}" alt="{$media/altText}" />
    </xsl:if>

    I hope it helps you

    /Dennis

  • TaoistTotty 246 posts 314 karma points
    May 23, 2011 @ 15:15
    TaoistTotty
    0

    Hi Fuji and Dennis

    Tried both of these without any luck.

    I know the media exists, and in-line XSLT was working before upgrade, but nothing now.

    This does not make any difference as to whether new or old schema is used.

    Thanks

    TT

  • Kim Andersen 1447 posts 2196 karma points MVP
    May 23, 2011 @ 15:55
    Kim Andersen
    0

    Hi TT

    When you tried Dennis' solution, you did remember to rename the alias in his code from imageAlias to sideImage, right?

    If you did, could you try printing out the sideImage-property like this:

    <textarea>
    <xsl:copy-of select="$currentPage/sideImage" />
    </textarea>

    Or even print out the durrent page to make sure that the property has a value. Like this:

    <textarea>
    <xsl:copy-of select="$currentPage" />
    </textarea>

    /Kim A

  • TaoistTotty 246 posts 314 karma points
    May 23, 2011 @ 16:21
    TaoistTotty
    0

    Hi Kim

    I did change the alias in Dennis' example.

    Tried the above and got the following output

     

    <sideImage>1059</sideImage>

    but running the $currentPage version seems to have output the whole site, and not just the one page.

    TT

  • Kim Andersen 1447 posts 2196 karma points MVP
    May 23, 2011 @ 16:29
    Kim Andersen
    0

    Hmm...okay could you then try printing out this:

    <textarea>
     
    <xsl:copy-of select="umbraco.library:GetMedia($currentPage/sideImage, 0)" />
    </textarea>

    Just to check if there's actually an image with that ID.

    /Kim A

  • TaoistTotty 246 posts 314 karma points
    May 23, 2011 @ 16:53
    TaoistTotty
    0

    Thanks for this.

    Have done this, and the site does not show, below where the image would go.

    Looking at the page using FireBug and the text from the HTML of the page is shown in the textaera, but excape codes are shown for the various elements.

     <textarea>
    </div>
    <div id="editable">
    <h1>About Us</h1>
    <p>Kernow Credit Union Ltd is open to anyone living and/or working
    in Cornwall.</p>

    <p>&nbsp;</p>

    <p>Credit Unions probably aren't the first place you think of when
    you're looking for a new savings account or personal loan. But
    perhaps it's time to think again. Credit unions offer their members
    cheap, flexible loans.</p>

    <p>&nbsp;</p>

    <p>If you borrowed £1,000 over one year, you'd be better off with a
    credit union than if you were with one of the most expensive banks
    or building societies.</p>

    <!-- Insert default "contactdetails" markup here -->



    </div>
    </div>
    <div id="third">
    </div>
    <div id="resize">
    </div>
    <div id="bottom">
    <div id="address">
    <p>Kernow Credit Union Ltd,
    The Chambers · Penryn Street · Redruth · Cornwall · TR15 2SP</p>
    </div>
    <div id="supportedby">
    <p><img src="/media/704/ukcreditunions.png" width="92" height="65" alt="ukcreditunions"/><img src="/media/709/cornwallcouncil.png" width="106" height="68" alt="CornwallCouncil"/><img src="/media/714/fsa.png" width="104" height="64" alt="fsa"/><img src="/media/719/fscs.png" width="132" height="65" alt="fscs"/></p>
    </div>
    <div id="auth">
    <p>Authorised & Regulated by The Financial Services Authority Firm number 223115</p>
    </div>
    </div>
    </div>
    </body>
    </html>
    </textarea>

    The node ID being shown when just using value-of is 1059, and this is an image (see screen shot below).

     

     The pages ID is 1055 (see image below).

     

    Thanks

    TT

  • TaoistTotty 246 posts 314 karma points
    May 23, 2011 @ 18:18
    TaoistTotty
    0

    Changing the image uploaded does not change this, but creating a new media items and then uploading the image does.

    Anybody know of a reason for this?

    Regards

    TT

Please Sign in or register to post replies

Write your reply to:

Draft