@inherits umbraco.MacroEngines.DynamicNodeContext
@{
var folderId = Model.GetPropertyValue("filfolder");
var chosenMedia = Model.MediaById(@folderId);
if (chosenMedia.NodeTypeAlias == "Folder")
{
foreach (var img in chosenMedia.Children)
{
if (img.NodeTypeAlias == "Image")
{
<img src="@img.umbracoFile"/>
}
}
}
}
The above is used for listing all media, of type "Image", in a folder with ID taken from a document type field.
Which data type should be used for chooseing the folder containing the images?
Right now the end user has to type in the folder ID into a textfield data type. I would rather have the user pick a media folder of choice. Both Media pickers cannot choose media folders only media images. The Content Picker can only choose document types from content.
Sorry my bad. I need to get used to the new 7 UX. The data type of choice is Media Picker and the user just needs to choose the grey "select" text under the folder icon. I was clicking on the actual folder icon.
Sorry for my bad English. I am Brazilian and I do not speak English.
In umbraco 6.x we could select the folder 'Media' using the data type 'Content Picker' and this returned the 'folder id'. However in U7 apparently this is not possible.
As I'm not have much time to research a elegant solution I create a personalized doctype 'Media Picker Legacy'. The user must select any file inside de media folder and this field retrieve the 'ID' of the media file. My routine gets the selected media file Id and list theirs sibilings.
This works but the solution is very ugly. If anyone have any suggestions I thanks a lot.
The snipped code below shows an example of the my code:
var mediaFile = Library.MediaById(mediaId); var mediaFolder = mediaFile.Parent;
@foreach (var mediaItem in mediaFolder.Children) { my razor code here listing de sibilings of selected media. }
Thanks for posting this, I was trying to achieve the same result with a custom controller and having a nightmare ! This enabled me to achieve the same result very very quickly. I just wish I'd spotted it a couple of days ago!
Whitch Data Type for choosing a Media Folder?
The above is used for listing all media, of type "Image", in a folder with ID taken from a document type field. Which data type should be used for chooseing the folder containing the images?
Right now the end user has to type in the folder ID into a textfield data type. I would rather have the user pick a media folder of choice. Both Media pickers cannot choose media folders only media images. The Content Picker can only choose document types from content.
Sorry my bad. I need to get used to the new 7 UX. The data type of choice is Media Picker and the user just needs to choose the grey "select" text under the folder icon. I was clicking on the actual folder icon.
I was strugling with the same issue. Maybe the text should read "select folder" instead.
Hi guys! I have the same problem too!
Sorry for my bad English. I am Brazilian and I do not speak English.
In umbraco 6.x we could select the folder 'Media' using the data type 'Content Picker' and this returned the 'folder id'. However in U7 apparently this is not possible.
As I'm not have much time to research a elegant solution I create a personalized doctype 'Media Picker Legacy'. The user must select any file inside de media folder and this field retrieve the 'ID' of the media file. My routine gets the selected media file Id and list theirs sibilings.
This works but the solution is very ugly. If anyone have any suggestions I thanks a lot.
The snipped code below shows an example of the my code:
Well, You can create a new Data type. Section>Developer=>Data types=> Create new with following options.
Thanks for posting this, I was trying to achieve the same result with a custom controller and having a nightmare ! This enabled me to achieve the same result very very quickly. I just wish I'd spotted it a couple of days ago!
Thanks anyhow !
Old post - using Umbraco 6.2
Add property "Media Picker" to doc type. In the content, pick the folder.
is working on a reply...