I'm new to Umbraco and I'm trying to use media picker on my site but for some reason the value is always null or empty.
I followed the steps in here but when inspecting the html code i get the following results:
<img class="img-fluid" src="" style="background-image: url('')" alt="">
Here is my code:
@{
Layout = "Master.cshtml";
var image = Model.Value<IPublishedContent>("mainImage");
if (image != null)
{
<img class="img-fluid" src="@image.Url" style="background-image: url('@image')" alt="" />
} }
In the Backoffice i added my image in Media first and i did click save and publish. backoffice
I'm running on version 8.14.1
As you are probably using the new (to 8.14+) media picker, you might need to do things a bit differently (like so: https://our.umbraco.com/Documentation/Fundamentals/Backoffice/Property-Editors/Built-in-Property-Editors/Media-Picker-3/ ) .