Copied to clipboard

Flag this post as spam?

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


  • Heine Stick 12 posts 92 karma points
    Jan 08, 2016 @ 13:04
    Heine Stick
    0

    Gallery preview function

    Hullo,

    I've created an image gallery feature. It works as intended. So far so good.

    I'm currently working on a gallery list feature, where all galleries are listed. The idea is to have the gallery's title, a link to the gallery itself, and the first three images appear in the list.

    The three images is what's causing me some headaches. I'm quite simply not able to get it to work. I've tried a few things, but no luck so far.

    Any pointers as to how to get it to work are much appreciated.

    The code sample is for the gallery itself.

    <xsl:variable name="mediaFolderId" select="number($currentPage/mediaFolderId)"/>
    <xsl:variable name="galleryTitle" select="$currentPage/galleryName"/>
    <xsl:variable name="galleryDescription" select="$currentPage/galleryDescription"/>
    <xsl:template match="/">
    <xsl:if test="number($mediaFolderId)">
        <h3><xsl:value-of select="$galleryTitle"/></h3>
        <xsl:value-of select="$galleryDescription"/>
        <div class="galleryContainer">
            <ul id="gallery" class=" gallery nolist">
                <xsl:for-each select="umbraco.library:GetMedia($mediaFolderId, true())/Image">
                    <xsl:if test="umbracoFile !=''">
                        <li>
                            <a href="{umbracoFile}" data-featherlight="">
                                <img src="/imageGen.ashx?image={umbraco.library:UrlEncode(umbracoFile)}&amp;width=150" />
                            </a>
                        </li>
                    </xsl:if>
                </xsl:for-each>
            </ul>
        </div>
    </xsl:if>
    

  • Heine Stick 12 posts 92 karma points
    Jan 08, 2016 @ 13:26
    Heine Stick
    0

    And this code is for the latest attempt at the gallery list. Admittedly I'm in deep waters, as this is the first time I've actually had to implement this sort of feature.

    <xsl:variable name="sourceNode" select="$currentPage/ancestor-or-self::landingPage"/>
    <xsl:variable name="mediaFolderId" select="number($sourceNode//mediaFolderId)"/>
    <xsl:variable name="maxImages" select="4" />
    <ul>
        <xsl:for-each select="umbraco.library:GetMedia($mediaFolderId, true())/Image">
            <xsl:if test="umbracoFile !='' and position() &lt; $maxImages">
                <li>
                    <a href="{umbracoFile}" data-featherlight="">
                        <img src="/imageGen.ashx?image={umbraco.library:UrlEncode(umbracoFile)}&amp;width=150" />
                    </a>
                </li>
    
            </xsl:if>
    </xsl:for-each>
    

Please Sign in or register to post replies

Write your reply to:

Draft