Could you explain in more details what you want to achieve? I get that you want to loop through images in a folder in the media gallery, but where do you get the folder from? Are you using a media picker on a node, or is the folder comming from a macro parameter?
If you have some existing code you could show us, it would be great so that we can make that work :)
Now the $folderContent should (if I didn't make any mistakes :) ) contain all of the XML that the selected folder contains, and you can run through the child nodes from there.
I haven't tried the above piece of code, but if this doesn't work, please try to print out the $folderContent variable in a textarea, and show us the returned XML :)
About the schema...when Umbraco 4.5 was released the XML schema was changed so the XSLT that needs to be written with 4.5 and above should have another syntax than the old schema. This is something that is confusing many people who are new to Umbraco since there are many examples on how to achieve stuff with XSLT in Umbraco using the old schema syntax. This is not an issue here since you get the image properties outputted.
What you need to do to create a list of the images now is this
get images using mediacurrent
hello folks,
i have placed my images(10 images) in folder(gallery) in mediacurrent.
how do i loop through all the images in the folder.
i am using umbraco version 4.6.1
thank you
Hi Ask
Could you explain in more details what you want to achieve? I get that you want to loop through images in a folder in the media gallery, but where do you get the folder from? Are you using a media picker on a node, or is the folder comming from a macro parameter?
If you have some existing code you could show us, it would be great so that we can make that work :)
/Kim A
i am unable to edit this question..
i have created folder(named as gallery) under media section in umbraco backend and will be adding images under this folder.
then i am creating a xslt macro with parameter "mediacurrent".
i will choose this folder(gallery) as source.
i would like to have script for looping through images in that selected folder or something like that .
thank you
Hi Ask
I can't remember what the mediaCurrent type returns, but could you try to print out whats in the parameter like this:
Then we can see what we have to work with.
/Kim A
it returns as like this if i choose folder in the media section of umbraco backend
<ImageSource>
<Folder id="1127" version="96be8528-ad92-4904-8b17-5e8499886d48" parentID="-1" level="1"
writerID="0" nodeType="1031" template="0" sortOrder="53" createDate="2011-03-03T19:38:41" updateDate="2011-03-03T19:38:41"
nodeName="gallery" urlName="gallery" writerName="admin" nodeTypeAlias="Folder"
path="-1,1127">
<contents />
</Folder>
</ImageSource>
Hi Ask
Could you try something like this then:
Now the $folderContent should (if I didn't make any mistakes :) ) contain all of the XML that the selected folder contains, and you can run through the child nodes from there.
Does that make sense?
/Kim A
Hi kim,
i tried this way
<xsl:variable name="mediaNode" select="/macro/mediaSource" />
<xsl:variable name="id" select="$mediaNode/Folder/@id" />
<xsl:if test="$id">
<xsl:variable name="folderContent" select="umbraco.library:GetMedia($id,1)" />
<xsl:value-of select="$folderContent"/>
<img src="{$folderContent}" alt="" height="200px" width="200px"/>
</xsl:if>
i got this output
/media/4119/img-1.jpg24413733015jpg/media/4127/img-3.jpg24413732463jpg/media/4137/img-7.jpg11313011397jpg
what should be schema for newer version?
i need to assign each image path to image src.
thank you
Try something like this:
I haven't tried the above piece of code, but if this doesn't work, please try to print out the $folderContent variable in a textarea, and show us the returned XML :)
/Kim A
Hi Ask
You can read more about using the GetMedia extension here: http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia
About the schema...when Umbraco 4.5 was released the XML schema was changed so the XSLT that needs to be written with 4.5 and above should have another syntax than the old schema. This is something that is confusing many people who are new to Umbraco since there are many examples on how to achieve stuff with XSLT in Umbraco using the old schema syntax. This is not an issue here since you get the image properties outputted.
What you need to do to create a list of the images now is this
<xsl:variable name="mediaNode" select="/macro/mediaSource" />
<xsl:variable name="id" select="$mediaNode/Folder/@id" />
<xsl:if test="$id">
<xsl:variable name="folderContent" select="umbraco.library:GetMedia($id,1)" />
<xsl:for-each select="$folderCOntent">
<ul>
<li><img src="{umbracoFile}" alt="" height="200px" width="200px"/></li>
</ul>
</xsl:for-each>
</xsl:if>
Try it out - it should to what you're requesting.
/Jan
thank you Mr.kim && Mr.Jan
Ahh great news hearing from you Ask :)
I'm glad that the solution above worked for you.
/Kim A
Hi Ask
Happy to hear you got it solved. Just out of couriosity...what does your working code look like now? :-)
/Jan
is working on a reply...