0
votes

I've media picker in my current Document Type. In that I have taken two Media picker. first for the multiple images slider and another for video.

enter image description here

And Content

enter image description here

Now I am trying to get this url in my code by given code:

var imageList = CurrentPage.productsSliderImages.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
var video = Umbraco.Media(CurrentPage.productSliderVideo);

I am getting ImageList successfully. But I am getting video null. If I replace my video with any Image again its start working. Is there any problem with Video or other file with media picker?

Watch:
http://prntscr.com/e9wal1

1
What is the file extension for the video you are picking? If my answer below is unhelpful, that could be a useful clue. Did you make a custom Media Type for the video? If so, what property editor are you using to store the video you are uploading?bowserm

1 Answers

2
votes

To resolve a problem like this, I would recommend trying to print the raw value of the video Media Picker to the screen or inspecting it in debug mode. I like to work with the more strongly typed IPublishedContent, so I would debug with some code like this:

var videoData = Model.Content.GetPropertyValue<string>("productSliderVideo");

Normally, if you are working on a View that inherits from @inherits UmbracoTemplatePage, both Model.Content and CurrentPage will give you the data on the current page. You can work with the CurrentPage if you like working with dynamics or you can work with Model.Content to work with more strongly typed IPublishedContent models. I prefer the strongly typed version because it is a lot easier for me to debug.

Once you verify that you are getting an id back, I would check the media item that you have picked in the backoffice just as a sanity check. Make sure it matches. If it does, I would try reindexing the InternalIndexer in the Examine Index Manager. As far as I understand, Umbraco uses the internal examine indexer as a media cache. After doing all of this, I would try the below. It is the same as what you are doing above, but with the TypedMedia instead of the dynamic media. Maybe it will reveal more to you. I personally find the typed content and typed media a lot easier to debug. It might make sense to switch over to that for the sake of debugging even if you decide you want to switch back to the dynamics afterwards:

var video = Umbraco.TypedMedia(videoData);