Copied to clipboard

Flag this post as spam?

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


  • Lee 4 posts 24 karma points
    Aug 12, 2010 @ 15:25
    Lee
    0

    Pulling photos from a media folder

    I have Umbraco 4.5.1 (asp.net v4) running on windows server 2003 (web).

    I have set a property called galImages (mediapicker) on a gallery doctype to specify which media folder to look through and then using this xslt code to return a simple set of img tags just with their source.

    <xsl:variable name="imageRoot" select="$currentPage/data [@alias='galImages']"/>
    <xsl:template match="/">
    <xsl:variable name="mediaItems" select="umbraco.library:GetMedia($imageRoot, true())"/>
    <xsl:for-each select="$mediaItems/node">               
    <img src="{current()/data[@alias='umbracoFile']}" />       
    </xsl:for-each>
    </xsl:template>

    I think this code may be a combination of new and old xslt, but I've tried various that I've found in the forum and elsewhere and set umbraco.config to use legacy xslt but no luck (came close a few times). The most frequent xslt error is this and the above code would raise it.

    System.OverflowException: Value was either too large or too small for an Int32.

    I have a few sites that pull this information but their xslt's with legacy=true didnt seem to work at all.

    I tried using '[LM] loop media folder Images' package (which worked well) but I couldn't set it to pick up the different media folders from the template depending on the galImages property.  If there is a way this would be a good solution for me but straight xslt would be better.

    Thanks for any help

    Lee

  • Matt Brailsford 4124 posts 22221 karma points MVP 9x c-trib
    Aug 12, 2010 @ 16:38
    Matt Brailsford
    0

    Hi Lee,

    Try the following:

    <xsl:variable name="imageRoot" select="$currentPage/galImages"/>

    <xsl:template match="/">
    <xsl:if test="string-length($imageRoot) &gt; 0">
    <xsl:for-each select="umbraco.library:GetMedia($imageRoot, '1')/Image">
    <img src="{umbracoFile}" />
    </xsl:for-each>
    </xsl:if>
    </xsl:template>

    Matt

  • Lee 4 posts 24 karma points
    Aug 12, 2010 @ 18:10
    Lee
    0

    Hi Matt

    Thanks for answering so quickly. 

    The string-length test seems to be failing but I do have a galImages media picker which is set to a media folder.

    Thanks

    Lee

  • Matt Brailsford 4124 posts 22221 karma points MVP 9x c-trib
    Aug 12, 2010 @ 18:53
    Matt Brailsford
    0

    I'd double check your alias names as they are case sensitive. Also try republishing your page to force it to resave. Could also check umbraco.config file to make sure it is all as you'd expect

    Matt

  • Brian A 13 posts 34 karma points
    Aug 12, 2010 @ 23:03
    Brian A
    1

    Hi Lee,

     

    I've just done the same on one of my sites - please check this:

    http://blackpoint.dk/umbraco-workbench/xslt/accessing-media-files.aspx?p=3

    Note that the parameter of the macro should be called "MediaNote".

    Have fun!

    /Brian

  • MartinB 411 posts 512 karma points
    Aug 12, 2010 @ 23:07
    MartinB
    0

    I have one here where the ID is hardcoded. It runs on the old schema (if you use that - can't tell):

     

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


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

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <xsl:variable name="mediaItems" select="umbraco.library:GetMedia(1075, true())"/>

    <xsl:for-each select="$mediaItems/node">
    <img src="{current()/data[@alias='umbracoFile']}" />
    </xsl:for-each>

    </xsl:template>

    </xsl:stylesheet>
  • Lee 4 posts 24 karma points
    Aug 12, 2010 @ 23:59
    Lee
    0

    Thanks Matt for your help.  The answer was I was using the legacy schema and hadn't set it back to false.  Thanks for pointing the way.

  • Lee 4 posts 24 karma points
    Aug 13, 2010 @ 00:11
    Lee
    0

    I want to high five you Brian but can't so I'll say it here...this would have helped loads. 

    Thanks guys for all your help.

    Lee

Please Sign in or register to post replies

Write your reply to:

Draft