"contactBannerBackgroundImage" property stores id of the media item, so you have to get Media item by id with Umbraco.TypedMedia(id) method and after that retrieve URL of the image.
Hi Alex, I wonder if you could help me a little further with this - I've had success with this code via templates - but it doesn't seem to work in Macro Partial Views.. any ideas?
But I have defined a title and image to be used in the 'content' tab - everything is set up correctly in the macro as well.. so I don't understand why the page doesn't have the pageBannerBackgroundImage value?
Setting an inline background image with the Media Picker
Hoping for a quick and easy solution to this - I have a media picker set up that would allow users to select a background image.
However, the following code set up in my partial view:
Is outputting as:
Any help appreciated!
Hi Stefan
Welcome to our forum!
Try this code:
"contactBannerBackgroundImage" property stores id of the media item, so you have to get Media item by id with Umbraco.TypedMedia(id) method and after that retrieve URL of the image.
Thanks,
Alex
Thanks for your help Alex, that worked perfectly!
Front end development is more my thing so I really appreciate the explanation.
You are welcome, Stefan
Have a great time with Umbraco :)
Alex
Hi Alex, I wonder if you could help me a little further with this - I've had success with this code via templates - but it doesn't seem to work in Macro Partial Views.. any ideas?
Hi Stefan,
Can you show all macro code?
Thanks,
Alex
Sure no problem:
I presume there's a slight variation in the calling method for Macros?
Stefan, please check that current page has value:
No error page, but the macro doesn't actually display on the page now.
No error page, but the macro is no longer displaying on the page either.
So the problem is that current page doesn't have "pageBannerBackgroundImage" property value.
But I have defined a title and image to be used in the 'content' tab - everything is set up correctly in the macro as well.. so I don't understand why the page doesn't have the pageBannerBackgroundImage value?
In the macro?
Where did you define image?
This method works with Current Umbraco Page, not the macro settings.
so, in the macro I have:
pageBannerBackgroundImage as an Alias for a media picker
In the macro partial view:
the code I pasted in (along with your amendments)
With the idea being, that via the media picker I can upload an image, and it will display as the background image
Sorry, I thought you have "pageBannerBackgroundImage" property on the page, you can use this code in this situation:
My man!! Thank you so much Alex
You are welcome, have a nice day!
is working on a reply...