Reputation: 195
How do I add the value in card.set to src="{% static 'images/Magic/4th Edition/Armageddon.full.jpg' %}"
in place of 4th Edition?
{% for card in sets %}
<div class="one-third column portfolio-item">
<div class="content">
<div class="border">
<img class="scale-with-grid" src="{% static 'images/Magic/4th Edition/Armageddon.full.jpg' %}" />
</div>
<center><h5 class="noline"><a href="#">{{card.set}}</a></h5></center>
</div>
<div class="shadow"></div>
</div>
{% endfor %}
Upvotes: 2
Views: 999
Reputation: 195
Whit the help of Gocht I got it to work with
{% with card.set|slugify as image_path %}
{% with 'images/Magic/'|add:image_path|add:'/Armageddon.full.jpg' as image_path %}
<img class="scale-with-grid" src="{% static image_path %}" />
{% endwith %}
{% endwith %}
Upvotes: 0
Reputation: 10256
Try this:
<img class="scale-with-grid" src="{% static 'images/Magic/{{ card.set }}/Armageddon.full.jpg' %}" />
EDIT:
Based on your comments, you could try this:
{% with 'images/Magic/'|add:card.set|add:'/Armageddon.full.jpg' as image_path %}
<img class="scale-with-grid" src="{% static image_path %}" />
{% endwith %}
Upvotes: 2