Files
2018-09-16 15:08:47 -04:00

34 lines
999 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 Ids 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 the media item associated with the id passed in *@
var media = Umbraco.TypedMedia(mediaId);
var selection = media.Children<Image>().ToArray();
if (selection.Length > 0)
{
<ul>
@foreach (var item in selection)
{
<li>
<img src="@item.Url" alt="@item.Name" />
</li>
}
</ul>
}
}