{% macro render_entity_link (entity, mbid, name) %}
  {%- if mbid is defined and mbid is not none -%}
    {% if entity == 'recording' %}
      {% set hostURL = 'https://musicbrainz.org' %}
    {% else %}
      {% set hostURL = '' %}
    {% endif %}
    <a href="{{ host }}/{{ entity }}/{{ mbid }}" target="_blank">
      {{ name|upper|e }}
      <title>{{ name|e }}</title>
    </a>
  {%- else -%}
    {{ name|upper|e }}
    <title>{{ name|e }}</title>
  {%- endif -%}
{% endmacro %}

{% macro render_image_link(entity, image) %}
  {% if image.entity_mbid %}
  <a href="/{{ entity }}/{{ image.entity_mbid }}" target="_blank">
  {% endif %}
    <image
        x="{{ image.x }}"
        y="{{ image.y }}"
        width="{{ image.width }}"
        height="{{ image.height }}"
        preserveAspectRatio="xMidYMid slice"
        href="{{ image.url }}">
        {% if image.title and image.artist %}
        <title>
          {{- image.title|escape ~ " - " ~ image.artist|escape -}}
        </title>
        {% endif %}
    </image>
  {% if image.entity_mbid %}
  </a>
  {% endif %}
{% endmacro %}
