Setting a background image via CSS

Alan Isaacson asked on January 5, 2016 13:06

I have a page which needs to display an image from a media library. I would prefer to set the image as a background image if possible. In the web part properties if I enter as part of an html envelope then nothing appears

<div class="clinImage" style="background-image:url({%# IllustrationImageFromMediaLibrary %});">

I can get the image to appear on the page but not as a background image if I use

<img src="{% IllustrationImageFromMediaLibrary %}" />

Any ideas on the best way to call in IllustrationImageFromMediaLibrary as a background image. Once I have done this I can then add other HTML elements for rollovers etc

Correct Answer

David te Kloese answered on January 5, 2016 13:56


It should work if you remove the #-sign.


<div class="clinImage" style="background-image:url({% IllustrationImageFromMediaLibrary %});">



1 votesVote for this answer Unmark Correct answer

Recent Answers

Alan Isaacson answered on January 5, 2016 14:22

Many thanks, thought it would be something small. Thats 6 hours I won't get back.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.