Using the media picker with an alias of sliderimage1.
This is far from ideal though. To be as dynamic as possible I want to use the Multiple Media Picker where you can upload x amount of images. The problem I have is displaying these accordingly.
So what I would like it to do is for every image in the Multiple Media Picker rendering a "li" with the appropiate image until all images are added to the slider.
1. The first option is to create a slideshow container documentype and a slideitem documenttype. So you could make a folder beside your home node and make it posible for the user to create elements of the slideshow container documenttype in the folder and under this container the user should be able to add the slideitem where you can add the picture for each slide. After that you need to write some XSLT get the data from the item, and pull out each slideitem.
The second method is faster, the user just pick a folder from the media library and then we will pull out all the images in this folder. So each image will be a slide.
I have made a example for the method two, where the user are picked a folder with image.
Sorry I can't get the above code to work for me but that is most likely my fault.
I have the following Multiple Media Picker connected to my 'Home'. Here I want to be able to upload the images. The alias of the Multiple Media Picker is multiMediaPicker.
For the carrousel the images need to be in a 'li' in the following structure.
Does anyone know how I can make this work or get the code above to work?
If I understand it right the code above tries to get all images out of the folder in my Media section? I have a folder called Slider with the images in it but if I try to point it there (change the sliderimage1 to Slider) it says "Value was either too large or too small for an Int32." aka it can't find anything.
Since you´re using the multi media picker you´re using umbraco 7.x.
Therefor I think that you should use Razor and make your Razor files as Partial View Macro Files. I think that you can use XSLT. unless you switch the engine to use webforms.
For any future users who come by this forum with the same question, I ended up using the following code because I had a path-issue with the above code:
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
var homepage = Model.Content.AncestorOrSelf(1);
if (homepage.HasValue("MultiMediaPicker"))
{
var imagesList = homepage.GetPropertyValue<string>("MultiMediaPicker").Split(new string[] {","}, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
var imagesCollection = Umbraco.TypedMedia(imagesList).Where(x => x != null);
foreach (var imageItem in imagesCollection)
{
<li>
<img src="@imageItem.Url" />
</li>
}
}
}
Multiple Media Picker
Hello everyone,
I am trying to learn Umbraco and to cover the media usage I am trying to create a slider (a simple fade-in/fade-out using JS).
I can get it to work with the following code:
-
Using the media picker with an alias of sliderimage1.
This is far from ideal though. To be as dynamic as possible I want to use the Multiple Media Picker where you can upload x amount of images. The problem I have is displaying these accordingly.
So what I would like it to do is for every image in the Multiple Media Picker rendering a "li" with the appropiate image until all images are added to the slider.
I hope I explained it well enough.
Hi Desley,
You have different options here.
1. The first option is to create a slideshow container documentype and a slideitem documenttype. So you could make a folder beside your home node and make it posible for the user to create elements of the slideshow container documenttype in the folder and under this container the user should be able to add the slideitem where you can add the picture for each slide. After that you need to write some XSLT get the data from the item, and pull out each slideitem.
To get XML from specific node. http://our.umbraco.org/wiki/reference/umbracolibrary/getxmlnodebyid-%281%29
The second method is faster, the user just pick a folder from the media library and then we will pull out all the images in this folder. So each image will be a slide.
I have made a example for the method two, where the user are picked a folder with image.
When you work with images i Umbraco I will recommened you to take a look at the ImageGen package.http://our.umbraco.org/projects/website-utilities/imagegen
With this package you can automatically resize photos, screenshots, and images from icon to thumbnail to full-screen retina sizes.
If you choose to use the ImageGen package you have to make some small changes to the piece of code above. You have to change this part:
To:
Hope this helps, and make sense. Or just keep asking and I will try to help you.
/Dennis
Sorry I can't get the above code to work for me but that is most likely my fault.
I have the following Multiple Media Picker connected to my 'Home'. Here I want to be able to upload the images. The alias of the Multiple Media Picker is multiMediaPicker.
For the carrousel the images need to be in a 'li' in the following structure.
I hope this makes it a bit clearer.
Sorry double post.
Does anyone know how I can make this work or get the code above to work?
If I understand it right the code above tries to get all images out of the folder in my Media section? I have a folder called Slider with the images in it but if I try to point it there (change the sliderimage1 to Slider) it says "Value was either too large or too small for an Int32." aka it can't find anything.
Help is greatly appreciated.
Hi Desley,
Since you´re using the multi media picker you´re using umbraco 7.x.
Therefor I think that you should use Razor and make your Razor files as Partial View Macro Files. I think that you can use XSLT. unless you switch the engine to use webforms.
But take a look at Jeavon´s solution here: http://our.umbraco.org/forum/developers/razor/46969-Displaying-Images-from-Multiple-Media-Picker
Hope this helps,
/Dennis
Okay got it to work!
Thanks for the help Dennis :)
For any future users who come by this forum with the same question, I ended up using the following code because I had a path-issue with the above code:
The issue I had is explained here
is working on a reply...