Nested Content template alias with MediaPicker3 and files
I want to show the name of a media file (PDF) within a Nested Content template alias field. I want to use it with the MediaPickerV3, so not the legacy version. When I put the alias ({{file}}) of the property in the template field, I get this:
There doesn't seem to be a name field present. In my Razor templates I would dig deeper with the .MediaItem property, but that doesn't seem to do anything in the template field. The documentation on this topic doesn't say anything about a media file.
Does anyone know if it's possible to show the name of the media item? Would love to know how!
I am trying to do the exact same thing! Did you figure it out?
We upgraded to Umbraco 10, but I think its mostly the same in this case.
Our nested content also had a custom Image picker, and we wanted to show the filename for. Because it uses a custom property editor that we wrote, I was able to modify that code to display the filename. I did this by adding the filename to the newMediaEntry (in JavaScript), before sending that object to the backend to save.
But for a built in property editor I fear it is impossible. Because you can't access the JavaScript code to add that property. When you save media, Umbraco adds it to the table: umbracoPropertyData (cmsPropertyData for v8 I think). What is saves to that table is this thing:
"[{"key":"b273a130-0f99-4eb1-94fc-650e4f489ff3","mediaKey":"a96e7ab3-407a-4b42-9bbb-c098d51b1e09","crops":[],"focalPoint":{"left":0.5,"top":0.5}}]"
Like I said, I was easily able to add the filename to that thing^ by adding it to the javascript that saved it. But you can't modify the javascript for an umbraco property ediotr....
Nested Content template alias with MediaPicker3 and files
I want to show the name of a media file (PDF) within a Nested Content template alias field. I want to use it with the MediaPickerV3, so not the legacy version. When I put the alias (
{{file}}
) of the property in the template field, I get this:There doesn't seem to be a name field present. In my Razor templates I would dig deeper with the
.MediaItem
property, but that doesn't seem to do anything in the template field. The documentation on this topic doesn't say anything about a media file.Does anyone know if it's possible to show the name of the media item? Would love to know how!
I am trying to do the exact same thing! Did you figure it out?
We upgraded to Umbraco 10, but I think its mostly the same in this case.
Our nested content also had a custom Image picker, and we wanted to show the filename for. Because it uses a custom property editor that we wrote, I was able to modify that code to display the filename. I did this by adding the filename to the newMediaEntry (in JavaScript), before sending that object to the backend to save.
But for a built in property editor I fear it is impossible. Because you can't access the JavaScript code to add that property. When you save media, Umbraco adds it to the table: umbracoPropertyData (cmsPropertyData for v8 I think). What is saves to that table is this thing: "[{"key":"b273a130-0f99-4eb1-94fc-650e4f489ff3","mediaKey":"a96e7ab3-407a-4b42-9bbb-c098d51b1e09","crops":[],"focalPoint":{"left":0.5,"top":0.5}}]"
Like I said, I was easily able to add the filename to that thing^ by adding it to the javascript that saved it. But you can't modify the javascript for an umbraco property ediotr....
Hi Sjoerd,
I don't know if it works in Nested Content, but it does work for BlockGrid and BlockList items:
{{(file[0].mediaKey | mediaItemResolver).name}}
or this alternative for older versions:
{{ "umb://media/" + file[0].mediaKey | ncNodeName }}
I got these from Joe Glombek's cheatsheet here: https://joe.gl/ombek/blog/umbraco-angularjs-filter-cheat-sheet
Hope this helps!
/Chriztian
Chriztian, thank you for the input. It worked for me in nested content!!!
However, I had to change it a little bit:
changed to
where "galleryImageSlideImage" is the alias of the image property on my document type.
is working on a reply...