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
Hey there
Im new to the umbraco platform :)
What im tryin to do is just using the standard media picker on a page where instead of selecting a single image(tried that and it working quickly).
So in the media picker im just picking a media folder instead, and I just want to print out the images through Razor.
@{ var mediaItems = Model.Media.galleryItem; foreach (var item in mediaItems) { <img src="@item.UmbracoFile" /> }}
"galleryItem" is the alias for the media picker.
Anyone got a quick comment for it :)
Comment author was deleted
Here is a quick example, it will output a single image if a single image is choses or all images if a folder is chosen
@inherits umbraco.MacroEngines.DynamicNodeContext@{ var numberOfItems = 10; }<ul> @foreach (var item in @Model.Children.Where("Visible").OrderBy("UpdateDate").Take(numberOfItems)) { <li>@item.Name if(item.HasValue("fileFromMedia")){ var chosenMedia = Model.MediaById(item.fileFromMedia); @if(chosenMedia.NodeTypeAlias == "Image") { <p>Single Image</p> <img src="@item.Media("fileFromMedia","umbracoFile")" width="200" /> } else if(chosenMedia.NodeTypeAlias == "Folder") { <p>Image gallery</p> foreach(var img in chosenMedia.Children) { <img src="@img.umbracoFile" width="200" /> } } }else{ <p>No image</p> } </li> }</ul>
Thumbs up Tim :)
First time im getting to use it after the course :)
Hi Rasmus,
Instead of selecting a folder you could also use the Digibiz Advanced Media Picker. There you can select multiple images. Here is a quick demo: http://www.screenr.com/gz0s.
Jeroen
Thx Jeroen :)
Always nice to know their are other choices aswell :) For this small project this should be enough
So for some reason when I try the above i get "The name 'ChosenMedia' does not exist in the current context"..Any idea why?
Thanks!
Amir
Ey Amir
Sorry for not gettin back to ya, dunno if you have gotten it to work but try this, its a simpler version, if not pls post your razor to me :)
@{ var chosenMedia = Model.MediaById(@Parameter.nodeSelector); if (chosenMedia.NodeTypeAlias == "Folder") { foreach (var img in chosenMedia.Children) { if (img.NodeTypeAlias == "Image") { <img src="@img.umbracoFile"/> } } } }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
simple gallery using standard media picker razor
Hey there
Im new to the umbraco platform :)
What im tryin to do is just using the standard media picker on a page where instead of selecting a single image(tried that and it working quickly).
So in the media picker im just picking a media folder instead, and I just want to print out the images through Razor.
"galleryItem" is the alias for the media picker.
Anyone got a quick comment for it :)
Comment author was deleted
Here is a quick example, it will output a single image if a single image is choses or all images if a folder is chosen
Thumbs up Tim :)
First time im getting to use it after the course :)
Hi Rasmus,
Instead of selecting a folder you could also use the Digibiz Advanced Media Picker. There you can select multiple images. Here is a quick demo: http://www.screenr.com/gz0s.
Jeroen
Thx Jeroen :)
Always nice to know their are other choices aswell :) For this small project this should be enough
So for some reason when I try the above i get "The name 'ChosenMedia' does not exist in the current context"..Any idea why?
Thanks!
Amir
Ey Amir
Sorry for not gettin back to ya, dunno if you have gotten it to work but try this, its a simpler version, if not pls post your razor to me :)
@{
var chosenMedia = Model.MediaById(@Parameter.nodeSelector);
if (chosenMedia.NodeTypeAlias == "Folder")
{
foreach (var img in chosenMedia.Children)
{
if (img.NodeTypeAlias == "Image")
{
<img src="@img.umbracoFile"/>
}
}
}
}
is working on a reply...