Instead of hard coding the image url, I've created a property on the Document Type called "headerPhoto" of type "Media Picker". How do I write the above div tag to use the Content headerPhoto url instead of the hard coded value?
I'm trying this, but the code is rendered literally. When I view the page in a browser and view source, I get the same code. It's not replacing it with a URL.
I tried this but it is still getting rendred literally. Both lines of code. Any other ideas? I'm new to Umbraco, but I thought there would be a macro to generate the image path.
How to get media image url in a template
I'm using Umbraco 6.1 and have the following code in a template:
<div style="background-image:url(/images/photo.jpg);">
Instead of hard coding the image url, I've created a property on the Document Type called "headerPhoto" of type "Media Picker". How do I write the above div tag to use the Content headerPhoto url instead of the hard coded value?
you can use one of them
I'm trying this, but the code is rendered literally. When I view the page in a browser and view source, I get the same code. It's not replacing it with a URL.
ok! i have not tested it but you can try this
var bgImage = Umbraco.Media(Model.Content.GetPropertyValue("headerPhoto"))
<divstyle="background-image:url(@bgImage.Url);"></div>
I tried this but it is still getting rendred literally. Both lines of code. Any other ideas? I'm new to Umbraco, but I thought there would be a macro to generate the image path.
This is the result I'm trying to acheive:
<div class="nav-backed-header parallax" style="background-image:url(/media/1031/building.jpg);">
Hi Joel,
Try this instead
is working on a reply...