Support #59699
page.mediaFiles
Start date:
2014-06-20
Due date:
% Done:
0%
Estimated time:
Description
Is it possible to cycle through »page media files«? For example:
I would like to show/output the second image (listNum = 1 or begin = 1) only. page.mediaFiles displays all images attached to the page.
Thanks.
Updated by Tim Klein-Hitpaß over 6 years ago
Hello Daniel!
As you can see in the default template for the view ( Resources / Private / Templates / Teaser / Index.html) the mediaFiles are already beeing cycled through.
<li><b>media:</b> <f:if condition="{page.mediaFiles}"> <f:then> <ul> <f:for each="{page.mediaFiles}" as="mediaFile"> <li> <f:image src="{mediaFile.url}" alt="{mediaFile.title}" maxWidth="200" maxHeight="200" /> </li> </f:for> </ul> </f:then> </f:if> </li>
Every mediaFile of a page is displayed (...<f:for each="{page.mediaFiles}" as="mediaFile">...)
If you want to display only one image you ca do that with fluid. Just replace the default template with your own template (via TS or in the flexform of the plugin).
You can try:
<li><b>only second media:</b> <f:if condition="{page.mediaFiles.1}"> <f:then> <f:image src="{page.mediaFiles.1.url}" alt="{page.mediaFiles.1.title}" maxWidth="200" maxHeight="200" /> </f:then> </f:if> </li>
Best regards!
tim
Updated by Daniel Schwarz over 6 years ago
Hey Tim,
thank you so much. Worked like a charm.
Best regards!
Daniel