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
How to create Image Gallery according to Folder Suppose, I am having 2 folders F1 and F2 i want images from F1 to be displayed first and then F2 in my frontend
Can anyone Help?
Hi Sagar,
Easy with a little MVC
Create a controller :-
class GalViewModel { public IEnumerable<string> Images { get; set; } } // controller public ActionResult GalAction() { var model = new GalViewModel() { Images = Directory.EnumerateFiles(Server.MapPath("FOLDERLOCATION")) .Select(fn => "FOLDERLOCATION" + Path.GetFileName(fn)) }; return View(model); }
Then create a partial view for the controller with the loop :-
@foreach(var image in Model.Images) { <img src="@Url.Content(image)" /> }
Of course you can do so much more but this is the most basic way i could think of doing it.
Regards, M
Thanks M T
What if I select Multiple Folders containing images in each from multi media Picker?
Ok I got it by Myself
@inherits Umbraco.Web.Macros.PartialViewMacroPage @{ var ms = ApplicationContext.Current.Services.MediaService; } @{ char[] splitChar = { ',' }; string[] ids = CurrentPage.file.ToString().Split(splitChar, StringSplitOptions.RemoveEmptyEntries); if (!string.IsNullOrEmpty(CurrentPage.file)) { foreach (var x in ids) { char[] splits = { ',' }; var dynamicmediaitem = Umbraco.Media(x); <h3>@dynamicmediaitem.Name</h3> <br/> foreach (var children in dynamicmediaitem.Children) { if (children.Children.Any()) { <img [email protected] /> } else { <img [email protected] /> } } <img [email protected] /> <br/> } } }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Image Gallery
How to create Image Gallery according to Folder Suppose, I am having 2 folders F1 and F2 i want images from F1 to be displayed first and then F2 in my frontend
Can anyone Help?
Hi Sagar,
Easy with a little MVC
Create a controller :-
Then create a partial view for the controller with the loop :-
Of course you can do so much more but this is the most basic way i could think of doing it.
Regards, M
Thanks M T
What if I select Multiple Folders containing images in each from multi media Picker?
Ok I got it by Myself
is working on a reply...