I have added a Document type, and added the Skyburd Image Picker as a Property in it.
I went to Content, and in my page added the data from the UI, which looks fine.
Now I am stuck, as previously I saw that for any text type, I would simply add @Umbraco.Field("Field Name") and that field will be shown. How do I add this Image picker here? If I try adding my field like before it simply prints Skybrud.ImagePicker.ImagePickerList . Which is definitely a type. Maybe I am missing something which is obvious to others. Maybe I need to search some more, but whatever it is please someone guide me in the right direction.
@Umbraco.Field("...") is mostly for getting simple values. You can't get the image picker value this way.
What you should do instead depends a bit on how your code looks. For instance, if you have a view that inherits from UmbracoTemplatePage, you can do it like this:
@using Skybrud.ImagePicker
@using Skybrud.ImagePicker.Extensions
@inherits UmbracoTemplatePage
@{
//@Umbraco.Field("imagePicker")
ImagePickerList list = Model.Content.GetImagePickerList("imagePicker");
if (list.IsValid)
{
foreach (ImagePickerItem item in list.Items)
{
<pre>@item.Image.Url</pre>
}
}
}
The GetImagePickerList is a special extension method from the image picker package. Alternatively you could use the GetPropertyValue instead:
@using Skybrud.ImagePicker
@inherits UmbracoTemplatePage
@{
//@Umbraco.Field("imagePicker")
ImagePickerList list = Model.Content.GetPropertyValue<ImagePickerList>("imagePicker");
if (list.IsValid)
{
foreach (ImagePickerItem item in list.Items)
{
<pre>@item.Image.Url</pre>
}
}
}
Cannot properly add Skybrud.ImagePicker
I am new to Umbraco, and am trying to add
Skybrud.ImagePicker
I have added a Document type, and added the Skyburd Image Picker as a Property in it.
I went to Content, and in my page added the data from the UI, which looks fine.
Now I am stuck, as previously I saw that for any text type, I would simply add @Umbraco.Field("Field Name") and that field will be shown. How do I add this Image picker here? If I try adding my field like before it simply prints Skybrud.ImagePicker.ImagePickerList . Which is definitely a type. Maybe I am missing something which is obvious to others. Maybe I need to search some more, but whatever it is please someone guide me in the right direction.
Thanks,
Hi Hammad,
@Umbraco.Field("...")
is mostly for getting simple values. You can't get the image picker value this way.What you should do instead depends a bit on how your code looks. For instance, if you have a view that inherits from
UmbracoTemplatePage
, you can do it like this:The
GetImagePickerList
is a special extension method from the image picker package. Alternatively you could use theGetPropertyValue
instead:Hope that helps ;)
is working on a reply...