Reference asset in theme configuration file/options


#1

Hello,

I am very relieved Grav exists because I was beginning to dislike the direction Wordpress was heading (bloated html and completely unnecessary javascript scripts loaded)…

Anyway, hopefully I’m not wasting anyone’s time with these simple questions…

What is this url type called? --> theme://images/logo.png

How can I call this type of reference url within my theme’s configuration file? My aim is for something as follows in a file called themes/my-first-theme/my-first-theme.yaml

dropdown:
  enabled: true
logo: theme://images/logo.png

So that within twig, I can use {{ theme_config.logo }}


#2

I feel like I am doing too many guessed replies lately, but it should be helpful to know that these are called PHP streams.

I don’t have a strong grasp on them yet, but I see examples in the docs that I follow successfully. Combined with the Twig url function, I think if you do this in your frontmatter, you should be able to access it with {{ theme_config.logo }}:

logo: "{{ url(theme://images/logo.png) }}"
process:
  twig: true

or maybe just logo: {{ theme://images/logo.png }} + process.twig and then reference your image URL with {{ url(theme_config.logo) }} if you want more flexibility with your image.


#3

Since I just had to research this …

logo: 'theme://images/example.svg'

And in Twig:

<img src="{{ url(theme_config.logo) }}">