Image actions applied to theme images?

Is it possible to apply image actions (ie: grayscale, resize, crop) to images from the theme directory? Something like this:

<img src="{{ url('theme://images', true) }}/my_image.png?grayscale">

Thanks in advance for your help.

An image usually needs to be associated with page for it to be treated as page media and therefore, have the media functions work correctly.

That said, you can put my_image.png under user/pages/images/my_image.png and reference it in markdown as:


In a twig file:

{{ "![](/images/test2.jpg?grayscale)"|markdown }}


{{ grav.pages.dispatch('/images').media['test2.jpg'].grayscale }}

Thanks for the info. Bummer on not being able to apply actions to theme images.

The reason for this is because these images associated with pages are sort of pre-processed during the page processing, and wrapped up in a Grav object that can do many things.

When you reference an image directly via an HTML tag, you are actually just asking the web server to send you the image. Grav is not running or processing.

It could be possible for a plugin to basically intercept a special request and do that work, but it would incur some performance penalty because it would mean running a Grav process for each image request you make.

BTW, this doesn’t happen with page images because these are processed and cached as actual image files, then referenced as such from the content. So there’s no performance penalty.

I understand. No worries. We’ll probably end up running them through that specific page so we can apply actions (as suggested). Thanks so much!