This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I am just trying to make personal theme. I have a problem with adding images into the layout. I made a layout called themes/october/layouts/home.htm and I need to add there a picture. Is here any function to find a root element? I tried to add it as assets/images/logo.png, but It does not work. Or must I write img src="theme/october/assets/images/logo.png" ? Can somebody help? Thanks
I tried with this and succeeded:
<div class="image-container">
<img class="my-class my-style" src=" https://mywebsite.com/themes/my_themes/assets/images/galeri/my-image.jpg ">
</div>
I uploaded an image that will be displayed on media gallery octobercms. Look at this picture: http://prntscr.com/rnoikv. You just need to drag and drop into scr = " ".
Last updated
kattsoff said:
Try something like <pre><code>src="{{ assets/images/logo.png | theme }}"</code></pre>
To echo @kattsoff, you are looking for the Theme filter. See this link in the October markup documentation, which provides some more details on how it works in Twig.
A quick excerpt:
"The |theme filter returns an address relative to the active theme path of the website. The result is an absolute URL, including domain and protocol, to the asset specified in the filter parameter. Theme assets usually reside in the assets subdirectory of a theme directory."
There are also others filters, like |app
and |media
, so I would recommend reading through the markup templating section of the OctoberCMS documentation for those specifically if you're working with assets this way.
1-6 of 6