Can't retrieve image URL from Umbraco.MediaPicker2
Hey!
So I wan't to make a macro that creates a list of all content pages posted of the document type "press", with text and image from every page.
Currently I'm able to get the text to show, but there seems to be a problem with getting the image.
I've been trying a lot of different things, but can't seem to get it to work. Searching hasn't been a help for me either.
I am using the media picker "Umbraco.MediaPicker2", which is attached to the document type of "press". The media pickers alias is "pressImg" and doesn't allow for multiple items to be picked.
I think the problem is that you are using Model.Content.AncestorOrSelf()
without any parameters. This will take just the current item and look for descendants of the type "press"
Can you try it with passing in the document type alias of your root node ?
The selection seems to work with and without it, as I'm able to get the text content from the selection, but the safety check for the image prevents any of it being posted.
Can't retrieve image URL from Umbraco.MediaPicker2
Hey!
So I wan't to make a macro that creates a list of all content pages posted of the document type "press", with text and image from every page.
Currently I'm able to get the text to show, but there seems to be a problem with getting the image.
I've been trying a lot of different things, but can't seem to get it to work. Searching hasn't been a help for me either.
I am using the media picker "Umbraco.MediaPicker2", which is attached to the document type of "press". The media pickers alias is "pressImg" and doesn't allow for multiple items to be picked.
Hoping someone's able to help me out :) Thanks in advance! - Mikkel
Hi Mikkel,
I think the problem is that you are using Model.Content.AncestorOrSelf() without any parameters. This will take just the current item and look for descendants of the type "press"
Can you try it with passing in the document type alias of your root node ?
Dave
Hey, thanks for your reply!
So I tried as you described, but there seems to be no difference, sadly.
The selection seems to work with and without it, as I'm able to get the text content from the selection, but the safety check for the image prevents any of it being posted.
Mikkel
Hi Mikkel,
Should have looked better at your code example. Can you try this
You were retreiving the image from the Model.Content, but that should be retreived from the item in the for loop
Dave
That did the trick!
Thanks a bunch!
I always get images-Urls like this
Hi Nadine
Do not use "Umbraco.Media" - it's dynamic type.
Always use Umbraco.TypedMedia()
Thanks,
Alex
is working on a reply...