Copied to clipboard

Flag this post as spam?

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


  • René 327 posts 852 karma points
    May 24, 2012 @ 14:52
    René
    0

    Xslt Get media path

    Umbraco ver: 4.7.2

    Hi im trying to get this result:

    /media/7009/1-Booking-Hotel-aarhus.jpg

    /media/7009/1-Booking-Hotel-aarhus.jpg128085390980jpg
    

     

    any ideas hov to remove the number after the image path, og how it gets there

     

    Here is my xslt 

    <?xml version="1.0" encoding="utf-8" ?>
    <xsl:stylesheet
            version="1.0"
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xmlns:umb="urn:umbraco.library"
            exclude-result-prefixes="umb"
            >

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

            <xsl:param name="currentPage" />
            <!--<xsl:variable name="mediaFolder" select="$currentPage/mediaFolder" />-->
            <xsl:variable name="mediaFolder" select="/macro/mediaFolder" />
     
            
            <xsl:template match="/">
              <xsl:if test="$mediaFolder[Folder]">
                            <xsl:variable name="media" select="umb:GetMedia($mediaFolder/Folder/@id, true())" />
                            
                            <!-- If no errors, this will run the Folder template below -->
                            <xsl:apply-templates select="$media[not(error)]" />
                            
                    </xsl:if>
            </xsl:template>
            
            <!-- Template for the folder -->
            <xsl:template match="Folder">
                    
                            <!-- Run templates for individual items (just add Media type aliases) -->
                            <xsl:apply-templates select="File | Image" />
                     
            </xsl:template>
            
            <!-- Template for items - you can create individual templates to render them differently -->
            <xsl:template match="File | Image">
             { src: '<xsl:apply-templates/>', fade: 4000},
               <!--<a href="{umbracoFile}"><img src="{umbracoFile}" /></a>--> 
              
            </xsl:template>
            </xsl:stylesheet>    

    Tanks in advance.. René

  • Fuji Kusaka 2203 posts 4220 karma points
    May 24, 2012 @ 15:00
    Fuji Kusaka
    0

    Hi Rene

    Can you try to change this 

     

      <xsl:variable name="media" select="umb:GetMedia($mediaFolder/Folder/@id, true())" />

    to

      <xsl:variable name="media" select="umb:GetMedia($mediaFolder/Folder/@id, true())/umbracoFile" />

     

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    May 24, 2012 @ 15:03
    Chriztian Steinmeier
    0

    Hi René,

    You're getting those numbers becuse the <xsl:apply-templates/> instruction you inserted will run through all the properties (umbracoFile, umbracoWidth etc.) - you just need to take the value of umbracoFile, like this:

    <xsl:template match="File | Image">
        <xsl:text />{ src: '<xsl:value-of select="umbracoFile" />', fade: 4000}<xsl:text />
        <xsl:if test="not(position() = last())">, </xsl:if>
    </xsl:template>

     

    /Chriztian

  • René 327 posts 852 karma points
    May 24, 2012 @ 15:06
    René
    0

    Hi 

    Tanks for the quick response..

    When i do this i get "The XSLT didn't generate any output"

    Kindly René

  • René 327 posts 852 karma points
    May 24, 2012 @ 15:18
    René
    0

    HI 

    Tanks a lot, you just saved my day... .

    This worked

    <xsl:templatematch="File | Image">
           
    <xsl:text/>{ src: '<xsl:value-ofselect="umbracoFile"/>', fade: 4000}<xsl:text/>
           
    <xsl:iftest="not(position() = last())">, </xsl:if>
    </xsl:template>

     

Please Sign in or register to post replies

Write your reply to:

Draft