Can I use < div > or something else to show a background image in a Markdown card?
I have this dynamically built card, but I want icons to span the part that shows a game (understanding that the resolution of the available icon might be too small):
This is my code:
type: markdown
title: Steam Games
content: |
{% if state_attr('sensor.steam_inventory', 'games') %}
{% for game in state_attr('sensor.steam_inventory', 'games') %}
### ![Icon für {{ game.name }}](https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/{{ game.appid }}/{{ game.img_icon_url }}.jpg) {{ game.name }}
**Play time:** {% set total_minutes = game.playtime_windows_forever %} {% set months = total_minutes // 43200 %} {% set days = (total_minutes % 43200) // 1440 %} {% set hours = ((total_minutes % 43200) % 1440) // 60 %} {% set minutes = (total_minutes % 43200) % 60 %} {% if total_minutes > 0 %} {% if months > 0 %}{{ months }} {{ 'month' if months == 1 else 'months' }}, {% endif %}{{ days }} {{ 'day' if days == 1 else 'days' }}, {{ hours }} hours, {{ minutes }} minutes{% else %}never played{% endif %}
{% if not loop.last %}
---
{% endif %}
{% endfor %}
{% else %}
No data found. Check sesnor.
{% endif %}
Sorry that I did not manage to properly format it. I use it as pasted here. As soon as I start using > or | the output of the value comes under the “Play time” in a new row - for all games - which I do not like. I hope you can understand my code nevertheless and help me to understand how/where to change it, so the source of the icon rather serves as the source for a background image.
Thanks for your help!
PS for users interested in how to use the required REST api sensor - here it is:
BTW, if somebody knows, if and how the above sensor code could take the url not being secret but only the Steam ID from secrets.yaml inserted, please drop me a line, too. I did not manage it and therefore placed the whole url into my secrets.yaml file.