What you could do is make use of Media Picker. Add Media Picker to your documentType "Homepage" then pick the folder you have the images store in media section.
If you are using razor you can try this
var mediaPicker = @Model.propertyAlias;
if (!String.IsNullOrEmpty(mediaPicker)){ int folderId = Convert.ToInt32(mediaPicker); var mediaFolder = new Media(folderId);
if (mediaFolder.ChildCount > 0) // Check if any Media Images present { IEnumerable Folder = mediaFolder.GetChildMedia().Where(x => x.ContentType.Alias == "Image"); // Here you can double check if media file is of type Image foreach (var img in Folder) {
c:\Websites\Veet2013Q1\Source\Veet.Web\macroScripts\635104094262690434_Home-carousel.cshtml(29): error CS0103: The name 'img' does not exist in the current context"
WAT I have done :
media picker name : mediaPicker
Media folder name : Homecarousel
cshtml : Home-carosel
inserted the macro Homecrsl in template.
@inherits umbraco.MacroEngines.DynamicNodeContext
@*
Model = The current page the macro is executed on
@Model.bodyText
Parameter = collection of parameter values passed from the macro
@Paramter.myParam
Library = utillity library with common methods
@Library.NodeById(1233)
*@
@* The fun starts here *@
var mediaPicker = @Model.companyMediaFolder;
if (!String.IsNullOrEmpty(mediaPicker)){
int folderId = Convert.ToInt32(mediaPicker);
var mediaFolder = new Media(folderId);
if (mediaFolder.ChildCount > 0) // Check if any Media Images present
{
IEnumerable<Media> Folder = mediaFolder.GetChildMedia().Where(x => x.ContentType.Alias == "Image"); // Here you can double check if media file is of type Image
if (!String.IsNullOrEmpty(mediaPicker)) { int folderId = Convert.ToInt32(mediaPicker); var mediaFolder = new Media(folderId); if (mediaFolder.ChildCount > 0)
@inherits umbraco.MacroEngines.DynamicNodeContext @using umbraco.cms.businesslogic.media; @{ var mediaPicker = @Model.mediaPickerH; if (!String.IsNullOrEmpty(mediaPicker)) { int folderId = Convert.ToInt32(mediaPicker); var mediaFolder = new Media(folderId);
pick images from folder to display in the slider of home page
Hi Guys n Gals
I want to do something fairly straightforward but can find no help for it.i need to develop a home page carousel.
now i want a macro which will pick the images from the a folder in media,and display them in the home page slider.
as per the rewquirements i have to create a macro to fetch the images from the folder in media.and display them on the page.
we are using the "flexslider" javascript to do the slider effect.
need urgently
Hi,
What you could do is make use of Media Picker. Add Media Picker to your documentType "Homepage" then pick the folder you have the images store in media section.
If you are using razor you can try this
Hope this helps
Hi thank u for quicke response...
Here is wat i get
"Error occured
c:\Websites\Veet2013Q1\Source\Veet.Web\macroScripts\635104094262690434_Home-carousel.cshtml(29): error CS0103: The name 'img' does not exist in the current context"
WAT I have done :
media picker name : mediaPicker
Media folder name : Homecarousel
cshtml : Home-carosel
inserted the macro Homecrsl in template.
@inherits umbraco.MacroEngines.DynamicNodeContext
@*
Model = The current page the macro is executed on
@Model.bodyText
Parameter = collection of parameter values passed from the macro
@Paramter.myParam
Library = utillity library with common methods
@Library.NodeById(1233)
*@
@* The fun starts here *@
var mediaPicker = @Model.companyMediaFolder;
if (!String.IsNullOrEmpty(mediaPicker)){
int folderId = Convert.ToInt32(mediaPicker);
var mediaFolder = new Media(folderId);
if (mediaFolder.ChildCount > 0) // Check if any Media Images present
{
IEnumerable<Media> Folder = mediaFolder.GetChildMedia().Where(x => x.ContentType.Alias == "Image"); // Here you can double check if media file is of type Image
foreach (var img in Folder)
{
<li><img src= "@img.getProperty("umbracoFile").Value" alt="" /></a></li>
}
}
can u suggest how to include the inputs...
sory to bother u again.....but imp
Ah add this namespace
@inherits umbraco.MacroEngines.DynamicNodeContext;
@using umbraco.cms.businesslogic.media;
var mediaPicker = @Model.companyMediaFolder;
if (!String.IsNullOrEmpty(mediaPicker))
{
int folderId = Convert.ToInt32(mediaPicker);
var mediaFolder = new Media(folderId);
if (mediaFolder.ChildCount > 0)
{
IEnumerable<Media> Folder = mediaFolder.GetChildMedia().Where(x => x.ContentType.Alias == "Image");
foreach (var img in Folder)
{
<li><img src= "@img.getProperty("umbracoFile").Value" alt="" /></a></li>
}
}
}
Error occured
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\d72e9d2d\ce918128\App_Web_635104126816380434_home-carousel.cshtml.70df5e80.hhewcmkl.0.cs(35): error CS1514: { expected
:(
Looks like you are missing @{ after the namespace !
int folderId = Convert.ToInt32(mediaPicker); var mediaFolder = new Media(folderId);
if (mediaFolder.ChildCount > 0)
IEnumerable<Media> Folder = mediaFolder.GetChildMedia().Where(x => x.ContentType.Alias == "Image");
} }
im am really sorry to ask u stupid qs...but it is also now working..
can u help in giving more details..like the name of folder,media picker, and how they should be refered in the cshtml and all
ver very urgent friend
can you please tell me which version of umbraco you are using and what property alias you are using for the media picker ?
umbraco v 4.11.8 (Assembly version: 1.0.4869.17899)
Type : Media Picker
name :mediaPickerH
alias : mediaPickerH
Folder name :Homecarousel
now can u please provide me with the cshtml code and name,razor name ..thank u in advance
Here you are dont forget to choose the folder from your homepage
dear friend u really rock
u saved my day thanks a lot i works like miracle
have a very nice day
is working on a reply...