How to use an image as a link (which is stored as an expression in jinja templating) in HTML

244 Views Asked by At

I have a data expression which is called

img_tweets = ['http://pbs.twimg.com/media/EQYzCP4VAAEN0UJ.jpg'] 

In jinja

{{img_tweets}}

I want to use the value (which is a url) in img_tweets as an image for one of my pages. I'm not sure how to do that. This is what I have:

<img alt="img" src={{img_tweets}}
     width="150" height="70">

Please let me know if this is not clear.

Thank you.

1

There are 1 best solutions below

4
On

According to the Jinja documentation, attribute values need to be wrapped in quotes. So in your case, you'd write:

<img alt="Tweets" src="{{ img_tweets[0] }}" width="150" height="70">