So this is my first post on Umbraco forums - aplogies in advance if my question sounds stupid OR if I don't frame it right... (ALSO AMAZING PLUGIN LEBLENDER IS - thanks lecoati team).
I have added a media picker (with selection of multiple items enabled) to my grid... I need to enable user to upload videos in multiple formats for a carousel am working on and I would like to access URLs of all the videos selected per media picker.
I am basing my solution on the Carousel view example that comes with Leblender. After tinkering around, I have below code working for me where "video" is my media picker property alias. My question is; is this the best way of doing this? I feel it's too verbose... Maybe someone has a more elegant solution? Thanks!
Side Question: Also which is the best way to customize CSS used by le blender to display in the grid? I am very new to Umbraco's GRID data type as it is and I can't wrap my head around it...
Welcome to our community )
1) You can get video URLs like that:
var videoUrl = item.GetPropertyValue<string>("video");
if (!string.IsNullOrWhiteSpace(videoUrl))
{
var vidList = videoUrl.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
var vidListCollection = Umbraco.TypedMedia(vidList);
if (vidListCollection != null)
{
foreach (var vid in vidListCollection)
{
<h1>@vid.Url</h1>
}
}
}
Does this work with the current version of LeBlender? I'm using the new Media Picker with multiple images allowed and I get the following error:
'Lecoati.LeBlender.Extension.Models.LeBlenderValue' does not contain a definition for 'GetPropertyValue' and the best extension method overload 'Umbraco.Web.PublishedContentExtensions.GetPropertyValue<T>
I could be wrong (especially since i haven't looked at the documentation before answering you) but my crystal balls tell me LeBlender exposes its own model to the partial view (BlenderModel). I think this model doesn't have a definition of 'GetPropertyValue' as Umbraco Render Model does. What exactly are you trying to achieve? List images? perhaps you could try something like below. Let me know if this helps :)
@inherits UmbracoViewPage<Lecoati.LeBlender.Extension.Models.LeBlenderModel>@if(Model.Items.Any()){foreach(variteminModel.Items){if(item.GetValue<string>("imagePropertyName")!=""&&item.GetValue<string>("imagePropertyName")!=null){//do something with your image...}}}
HI Japeth, the issue I was having I think (in addition to the GetPropertyValue issue) is that it was stored as CSV. Here's what ended up working for me.
var item = Model.Items.ElementAt(0);
var imageList = item.GetValue<string>("multiImageSlider"); if (!string.IsNullOrWhiteSpace(imageList)) { var vidList = imageList.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
var vidListCollection = Umbraco.TypedMedia(vidList);
if (vidListCollection != null) { foreach (var vid in vidListCollection) { <li><img src="@vid.Url"></li> } } } }
Looping through Media Picker with multiple items
Hi guys,
So this is my first post on Umbraco forums - aplogies in advance if my question sounds stupid OR if I don't frame it right... (ALSO AMAZING PLUGIN LEBLENDER IS - thanks lecoati team).
I have added a media picker (with selection of multiple items enabled) to my grid... I need to enable user to upload videos in multiple formats for a carousel am working on and I would like to access URLs of all the videos selected per media picker.
I am basing my solution on the Carousel view example that comes with Leblender. After tinkering around, I have below code working for me where "video" is my media picker property alias. My question is; is this the best way of doing this? I feel it's too verbose... Maybe someone has a more elegant solution? Thanks!
Side Question: Also which is the best way to customize CSS used by le blender to display in the grid? I am very new to Umbraco's GRID data type as it is and I can't wrap my head around it...
Hi Japheth,
Welcome to our community ) 1) You can get video URLs like that:
Also you can write your own property value converter, documentation here : https://our.umbraco.org/documentation/extending-umbraco/property-editors/value-converters-v7
http://www.theoutfield.net/blog/2013/04/strongly-typed-property-values-using-property-editor-value-converters-in-umbraco
Thanks, Alex
Thanks Alex! That works perfectly :) Unfortunately I do not have enough Karmas yet to upvote your answer but thanks :p
Does this work with the current version of LeBlender? I'm using the new Media Picker with multiple images allowed and I get the following error:
'Lecoati.LeBlender.Extension.Models.LeBlenderValue' does not contain a definition for 'GetPropertyValue' and the best extension method overload 'Umbraco.Web.PublishedContentExtensions.GetPropertyValue<T>
-Amir
Hi Amir, yes it works with latest version.
I could be wrong (especially since i haven't looked at the documentation before answering you) but my crystal balls tell me LeBlender exposes its own model to the partial view (BlenderModel). I think this model doesn't have a definition of 'GetPropertyValue' as Umbraco Render Model does. What exactly are you trying to achieve? List images? perhaps you could try something like below. Let me know if this helps :)
HI Japeth, the issue I was having I think (in addition to the GetPropertyValue issue) is that it was stored as CSV. Here's what ended up working for me.
is working on a reply...