Files
LeafWeb/WebCms/Umbraco/PartialViewMacros/Templates/ListImagesFromMediaFolder.cshtml
T
2016-11-07 12:56:17 -05:00

34 lines
992 B
Plaintext

@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
Macro to display a series of images from a media folder.
How it works:
- Confirm the macro parameter has been passed in with a value
- Loop through all the media Id's passed in (might be a single item, might be many)
- Display any individual images, as well as any folders of images
Macro Parameters To Create, for this macro to work:
Alias:mediaId Name:Select folder with images Type:Single Media Picker
*@
@{ var mediaId = Model.MacroParameters["mediaId"]; }
@if (mediaId != null)
{
@* Get all the media item associated with the id passed in *@
var media = Umbraco.Media(mediaId);
var selection = media.Children("Image");
if (selection.Any())
{
<ul>
@foreach (var item in selection)
{
<li>
<img src="@item.umbracoFile" alt="@item.Name" />
</li>
}
</ul>
}
}