I am new in using Umbraco CMS. I am having hard time making the image from Image Media Picker as a background. Please see the code below for your reference.
headerImage will most likely return a MediaWithCrops object (as that is wat the image picker returns).
So you are currently trying to print the object itself, which will not work. You need the code to know what kind of object it is, so you can get the properties of that object.
You could try this above the Header tag
@{
if (Model.Value("headerImage") is MediaWithCrops imageObject)
{
@imageObject.Url();
}
}
How to set Image Media Picker as a background
Hello,
I am new in using Umbraco CMS. I am having hard time making the image from Image Media Picker as a background. Please see the code below for your reference.
headerImage will most likely return a MediaWithCrops object (as that is wat the image picker returns).
So you are currently trying to print the object itself, which will not work. You need the code to know what kind of object it is, so you can get the properties of that object.
You could try this above the Header tag
This would print the URL above the header.
So in total you could do something like this:
It however is var easier to have Typed values. Worth looking into it for Umbraco, so you could easily do Model.HeaderImage.Url()
Introduction to Modelsbuilder
Models builder settings
is working on a reply...