Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Is it possible to use a DAMP media picker to select multiple folders, and also multiple images?
Right now i'm using the following code to display selected images, but as soon as I also select a folder this code will fail.
<umbraco:Macro runat="server" language="cshtml">@inherits umbraco.MacroEngines.DynamicNodeContext @foreach (var item in Model.images.mediaItem) { var image = item.Image; <a href="@image.umbracoFile"> <img alt="@image.nodeName" src="@image.umbracoFile"> </a> }</umbraco:Macro>
Logical as a folder likely won't have an Image property.
Is there a method that I can use to display the XML structure for an DAMP item?
Hello,
The DAMP xml is stored in the umbraco.config file (/App_Data/umbraco.config). There you can see your xml and you can chance your Razor code to support both multiple folders and images. This is possible :).
Jeroen
Hi Jeroen,
Thanks for the quick response, I will look into this right away.
Patrick
For now I came up with something like this:
<umbraco:Macro runat="server" language="cshtml"> @inherits umbraco.MacroEngines.DynamicNodeContext @using umbraco.MacroEngines; @{ foreach (var item in Model.images.mediaItem) { var images = item.XPath("Image"); if(images != null) { foreach (var image in images) { <a href="@image.umbracoFile"> <img alt="@image.nodeName" src="@image.umbracoFile"> </a> } } var folders = item.XPath("Folder"); if(folders != null) { foreach (var folder in folders) { var media = Model.MediaById(folder.id); var folderImages = media.Children; foreach(var folderImage in folderImages) { <a href="@folderImage.umbracoFile"> <img alt="@folderImage.nodeName" src="@folderImage.umbracoFile"> </a> } } } } } </umbraco:Macro>
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Combining image and folder selection with DAMP (with razor)
Is it possible to use a DAMP media picker to select multiple folders, and also multiple images?
Right now i'm using the following code to display selected images, but as soon as I also select a folder this code will fail.
Logical as a folder likely won't have an Image property.
Is there a method that I can use to display the XML structure for an DAMP item?
Hello,
The DAMP xml is stored in the umbraco.config file (/App_Data/umbraco.config). There you can see your xml and you can chance your Razor code to support both multiple folders and images. This is possible :).
Jeroen
Hi Jeroen,
Thanks for the quick response, I will look into this right away.
Patrick
Hi Jeroen,
For now I came up with something like this:
<umbraco:Macro runat="server" language="cshtml">
@inherits umbraco.MacroEngines.DynamicNodeContext
@using umbraco.MacroEngines;
@{
foreach (var item in Model.images.mediaItem)
{
var images = item.XPath("Image");
if(images != null)
{
foreach (var image in images)
{
<a href="@image.umbracoFile">
<img alt="@image.nodeName" src="@image.umbracoFile">
</a>
}
}
var folders = item.XPath("Folder");
if(folders != null)
{
foreach (var folder in folders)
{
var media = Model.MediaById(folder.id);
var folderImages = media.Children;
foreach(var folderImage in folderImages)
{
<a href="@folderImage.umbracoFile">
<img alt="@folderImage.nodeName" src="@folderImage.umbracoFile">
</a>
}
}
}
}
}
</umbraco:Macro>
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.