Roots Discourse

Inline background image not showing

I’m trying to add an inline background image in a Sage 10 template, but the path just doesn’t to be working:

<div style="background-image: url(../images/image.svg)"> .....

But if I add the full path below, it seems to work:

<div style="background-image: url(/app/themes/ez/dist/images/image.svg)"> .....

What is the best method to access this image?

Thanks

For anyone else looking for this answer, here is the solution:

<div style="background: url(@asset('images/image.svg'));">

1 Like

Tip: If you want to have user-selectable backgrounds, you can use templates and the template class.
Or a block style for a particular Gutenberg block.

1 Like