oTree Forum >

Dynamic image paths

#1 by Hauke

Hi all,

I am working with pictures using something like <img src="{{ static 'models/image_name_B.png' }}"> in my template.

I would now like to manipulate the <image_name> from within the __init__.py file. 

Nesting the curly brackets to include a var_for_template seems not to work. I guess that an absolute file path à la <img src="static/modelsHCP1A.png"> may do the trick (?) However, I cannot find the correct route of that path. Any suggestions?

Thanks in advance
Hauke

#2 by Hauke

Nevermind,

<img src="/static/image_name_A.png"> works

#3 by Chris_oTree

See here: https://otree.readthedocs.io/en/latest/templates.html#dynamic-images

Write a reply

Set forum username