Moodle 4 : Using Images in Renderer Overrides

Moodle 4 : Using Images in Renderer Overrides

If you’re looking to customise your theme or plugin by using a specific image in a renderer override, it’s actually quite simple! Just follow these two steps:

Upload the image file (e.g. IMAGENAME.png) to the “pix” folder in your theme or plugin. This will make sure that the image is accessible to the code when referenced.

Use the following code in your function to return the url:

$this->image_url('IMAGENAME', 'theme') 

to reference the image you want. This will ensure that the image is loaded in the renderer override. Note if you are using a plugin you’ll want to reference the component plugin name rather than “theme”.

And that’s it! With these two simple steps, you can easily use any theme or plugin image in your renderer override.

Documentation : docs.moodle.org

Comments are closed.