Media.Picker3 returning null for filesv

Hi

I have field of Umbraco.MediaPicker3, this has been upgraded from Media Picker (legacy) and from Umbraco 8 to 16. Problem is that it returns null for files ( .pdf, .docx ) works as expected for images.

I have the following code to return the media for files:

var attachment = Model.Value<IEnumerable<IPublishedContent>>(“fileAttachemnt“)

Anyone comes across this issue ?

Dibs

Hi Dibs👋

Just checking - you have a typo in the property alias (fileAttachemnt => fileAttachment ?) – would be sad to find out after years of debugging that the culprit was that!

Otherwise I’d suspect that you could try using IEnumerable<MediaWithCrops> as the type (as per the documentation here: Media Picker | Umbraco CMS) to see if that gets you closer?

/Chriztian

Hi Chrizitian

That is a typo placeholder for raising my topic : )

But like you say the underlining code i.e Models Builder creates the type ( field ) as MediaWithCrops, and the orignal code was :

As they are not images and are files they dont have crops, the actual file within the media section is of media type file.

Dibs

Hi All

After reading

and toggling on Pick multiple items allowed Models Builder to recreate the field as:

public virtual global:: System.Collections.Generic.IEnumerable<global::Umbraco,Cms.Core.Models.MediaWithCorps> FileAttachment => this.Value<global::System.Collections.Generic.IEnumerable<global::Umbraco.Cms.Core.Models.MediaWithCrops>>(_publishedValueFallback, “fileAttachment“);

This retuned the items in the fields as expected : )

DIbs

2 Likes