Home > other >  not able to display image using a variable to store image URL
not able to display image using a variable to store image URL

Time:12-24

enter image description here

I have stored the image URL in cover_url variable.

When I display the image using the variable, its broken but when I paste directly the URL, it works!

What am I doing wrong here?

CodePudding user response:

You forgot to add the quotes for the html to know that the src attribute is a string. This the output when you print the variable.

<center><img src=https://i.scdn.io/... /></center>

This way, what comes after your src attribute isn't considered as a string. The solution in your case would be just by adding the quotes symbol.

<center><img src="{cover_url}" /></center>

Hope this was helpful.

  • Related