Copied to clipboard

Flag this post as spam?

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


  • Joachim 16 posts 36 karma points
    Oct 16, 2014 @ 16:05
    Joachim
    0

    Problems getting a list of images from a list of media ID's

    Hello, I am trying to get a list of images from a list of ID's, here is what I go so far;

     

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


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

    <xsl:template match="/">

        <!-- First we check that the media idList is not empty -->
        <xsl:if test="$idList">

            <ul>

                <xsl:for-each select="$idList/value">

                    <xsl:variable name="id" select="umbraco.library:GetMedia(., false())" />

                    <li>

                        <!-- Output the URL using umbraco.library's NiceUrl method -->                   
                        <img src="{$id/umbracoFile}" alt="{$id/@nodeName}" border="0" title="{$id/imageText//value[lang(Culture:GetName())]}" />

                    </li>

                </xsl:for-each>

            </ul>

        </xsl:if>

    </xsl:template>
    </xsl:stylesheet>

    Sadly the code does not work at all, I simply want to get a list of the images from an array of media ids, what am I doing wrong here?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Oct 16, 2014 @ 19:11
    Jan Skovgaard
    0

    Hi Joachim

    Is the ID coming from a rich text editor macro? And what version of Umbraco are you using? I'm asking since it matters in regards to wether the old legacy XML schema is being used or if it's the newest one introduced in Umbraco 4.5.

    If you just write what does it then return?

    /Jan

  • Robin 37 posts 109 karma points
    Nov 01, 2014 @ 13:26
    Robin
    0

    Hi,

    Maybe this forum thread can help. It first gets ID's from images in a folder, and afterwards it list them in html.

    http://our.umbraco.org/forum/developers/xslt/57553-List-images-in-a-folder-fails

     

    Robin

Please Sign in or register to post replies

Write your reply to:

Draft