Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

template image path

Go to End

3 Posts   5332 Views


Community Member, 3 Posts

8 March 2011 at 9:38pm


I'm just starting up with SilverStripe and I have a question about the image-path in templates, maybe a logo or something other that does'nt hange.

I do my own template with an image inside of it.

What is the relative path URL to my own template-images-folder? Did you have a image - variable for it, or, how does it work?

<img src="images/image.png" alt="" title="where's my image???" />
From where must be set the relative path, from root does not work?

Thanks, kazuhisa


Forum Moderator, 1848 Posts

8 March 2011 at 10:34pm

If the control you are in

class MyDataObject extends DataObject {
$has_one = array('MyImage' => Image);

you can...

<% control MyDataObject %>
<% control MyImage %><img  src="$URL" alt="$Title" /><% end_control %>
<% end_control %>

or if the image is in the theme dir or mysite folder...

<img src="{$BaseHref}/images/myimage.png">
<img src="$ThemeDir/images/myotherimage.png">


Community Member, 3 Posts

8 March 2011 at 10:46pm

Thanks a lot, I'm just find where I'm looking for:
inline css in template because I had the same question about the css-path.

Thanks for your answer, $ThemeDir does work fine.