Copied to clipboard

Flag this post as spam?

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


  • Brian Milman-Hurst 48 posts 76 karma points
    Apr 18, 2013 @ 20:46
    Brian Milman-Hurst
    0

    Use Media n XSLT instead of upload

    Hi again guys,

    Sorted my previous issue but I now have a 'nice to have' issue that I could do with some help with fixing.

    I have an XSLT file that currently utlises an uploaded image called 'featuredImage' but I would like to amend this to be a file from the Media instead.  Alas my poor knowledge of all things XSLT is letting me down once more and I wonder if any of you kind guys would help me and point me in the right direction.

    here is the code, thanks guys

     

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


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

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <!-- start writing XSLT -->
      <xsl:variable name="sliderNode" select="$currentPage/AvailableList/availablesubgroup/PropertyDetails "/>

     <div id="slider">
        <div id="imageSlider">
          <xsl:for-each select="$sliderNode">
               <href="{umbraco.library:NiceUrl(@id)}"><div class="imageSlide">
                  <div class="imageSliderInfo">
                      <h2<xsl:value-of select="@nodeName"/></h2>
                    <p><xsl:value-of select="numberOfBedrooms"/> bedrooms <xsl:value-of select="costOfProperty"/></p>
                    </div>
                    <div class="imageSliderImage">
                      <img src="{featuredImage}" width="666" height="420" />
                    </div>
                  </div></a>
           
          </xsl:for-each>
       </div>
    </div>
    </xsl:template>

    </xsl:stylesheet>

  • Rich Green 2246 posts 4008 karma points
    Apr 18, 2013 @ 20:57
    Rich Green
    0

    http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia

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

     
    <xsl:iftest="$media">
           
    <xsl:variable name="url"select="$media/umbracoFile"/>
           
    <xsl:variable name="width"select="$media/umbracoWidth"/>
           
    <xsl:variable name="height"select="$media/umbracoHeight"/>
           
    <img src="{$url}"width="{$width}"height="{$height}"/>
     
    </xsl:if>

    Rich

  • Rich Green 2246 posts 4008 karma points
    Apr 18, 2013 @ 20:58
    Rich Green
    1

    Formatting broke, this one:

    <xsl:variablename="media"select="umbraco.library:GetMedia(featuredImage, 0)"/>

     
    <xsl:if test="$media">
           
    <xsl:variablename="url"select="$media/umbracoFile"/>
           
    <xsl:variablename="width"select="$media/umbracoWidth"/>
           
    <xsl:variablename="height"select="$media/umbracoHeight"/>
           
    <imgsrc="{$url}"width="{$width}"height="{$height}"/>
     
    </xsl:if>
  • Rich Green 2246 posts 4008 karma points
    Apr 18, 2013 @ 21:02
    Rich Green
    0

    Still broke (there should be spaces after 'variable') darn editor! Hopefully you get the idea.

    Rich

  • Brian Milman-Hurst 48 posts 76 karma points
    Apr 19, 2013 @ 08:42
    Brian Milman-Hurst
    0

    Rich, you are a gent and a scholar... thanks very much!

     

    and yep, certainly got the idea

     

    Bri

Please Sign in or register to post replies

Write your reply to:

Draft