Copied to clipboard

Flag this post as spam?

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


  • David Tak 7 posts 27 karma points
    Aug 08, 2012 @ 14:09
    David Tak
    0

    I need help with media library

    Hi

    I'm still working out the kicks of everything and don't really understand everything so it could be something that already is explained somewhere

    anyway

    i've got a carousel image thing on my site

    i want it to grab the images that it uses out of my media library

    how can i do this

    i was thinking of an xslt but i don't know how to write it

    example:

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


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

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

            <div id="rotating-item-wrapper">
              <img class="rotating-item" src="/images/img/photos/1.jpg"  />
              <img class="rotating-item" src="/images/img/photos/2.jpg"  />
              <img class="rotating-item" src="/images/img/photos/3.jpg"  />
              <img class="rotating-item" src="/images/img/photos/4.jpg"  />
            </div>

    </xsl:template>

    </xsl:stylesheet>

     

    so change the img files so it selects these images from my media library

    so i don't have to keep changing the code

     

    Please help me

     

     

     

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Aug 08, 2012 @ 14:21
    Chriztian Steinmeier
    1

    Hi David,

    Here's a very simple way to do it:

    Create a property called Media Folder and choose the Media Picker Data Type (It should get the alias mediaFolder).

    Now replace the <xsl:template match="/"> ... </xsl:template> in the above XSLT with these three templates:

    <xsl:template match="/">
        <xsl:variable name="mediaFolderId" select="$currentPage/mediaFolder" />
        <!-- Make sure a folder was picked -->
        <xsl:if test="normalize-space($mediaFolderId)">
            <xsl:variable name="mediaFolder" select="umbraco.library:GetMedia($mediaFolderId, true())" />
    
            <!-- Process folder, if it exists -->
            <xsl:apply-templates select="$mediaFolder[not(error)]" />
        </xsl:if> 
    </xsl:template>
    
    <xsl:template match="Folder">
        <div id="rotating-item-wrapper">
            <!-- Process images in folder -->
            <xsl:apply-templates select="Image" />
        </div>
    </xsl:template>
    
    <xsl:template match="Image">
        <img class="rotating-item" src="{umbracoFile}" width="{umbracoWidth}" height="{umbracoHeight}" />
    </xsl:template>

     

    On the document you can now select a folder in your Media Section and have all the images processed by the single Image template.

    /Chriztian

  • David Tak 7 posts 27 karma points
    Aug 08, 2012 @ 17:55
    David Tak
    0

    Thanks a million i have been looking and trying to find a solution.

    exactly what i needed

     

    Greets

     

    David

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 08, 2012 @ 19:03
    Fuji Kusaka
    0

    As usual thumbs up for Chriztian. Awesome.

Please Sign in or register to post replies

Write your reply to:

Draft