We're experimenting building a small site with v5, and while it has some benefits figuring out how to "do stuff you did before" is a challenge.
One such challenge is we're trying to randomly display an image picked among all images in a particular media folder. Previously we were able to do this with something like...
<span> @{ // ### random image from 740x310 pics folder ### dynamic folder = Library.MediaById( *** the numeric ID of the media folder here *** ); var image = folder.Children.Where("nodeTypeAlias = \"Image\"").Random(); } <img src="@image.UmbracoFile" alt="@image.Name" /> </span>
</umbraco:Macro>
But for the life of me, we can't figure out how to do this in v5. Any thoughts/ideas/suggestions?
Using Library.MediaById in v5
Hi All,
We're experimenting building a small site with v5, and while it has some benefits figuring out how to "do stuff you did before" is a challenge.
One such challenge is we're trying to randomly display an image picked among all images in a particular media folder. Previously we were able to do this with something like...
<umbraco:Macro runat="server" language="cshtml">
@inherits umbraco.MacroEngines.DynamicNodeContext
<span>
@{
// ### random image from 740x310 pics folder ###
dynamic folder = Library.MediaById( *** the numeric ID of the media folder here *** );
var image = folder.Children.Where("nodeTypeAlias = \"Image\"").Random();
}
<img src="@image.UmbracoFile" alt="@image.Name" />
</span>
</umbraco:Macro>
But for the life of me, we can't figure out how to do this in v5. Any thoughts/ideas/suggestions?
is working on a reply...