2

i'm using Flask with Python and want to insert an Image.
That works fine with following command:

{{ url_for('static', filename='path/to/img.jpg') }}

But now i want to insert an image in a loop (like for articles) and need the path out of a variable like:

{{ article.header_img_path }}

How can i insert a variable path into the

{{ url_for('static', filename='path/to/img.jpg') }}

command?
Something like that:

{{ url_for('static', filename=' {{ article.header_img_path }} ') }}


Is there a better way to do that or is just my syntax corrupt?


Thanks for your advise!

0

1 Answer 1

3

The variable should be passed to filename without quotes or braces.

{{ url_for('static', filename=article.header_img_path) }}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.