Browse Source

Image gallery fix

imwald
Nuša Pukšič 3 months ago
parent
commit
d02408ceb1
  1. 138
      templates/event/index.html.twig

138
templates/event/index.html.twig

@ -120,61 +120,59 @@
<div class="event-content"> <div class="event-content">
<twig:Atoms:Content :content="event.content" /> <twig:Atoms:Content :content="event.content" />
</div> </div>
{% endif %} {# Collect all imeta images into an array #}
{% set images = [] %}
{# Collect all imeta images into an array #} {% for tag in event.tags %}
{% set images = [] %} {% if tag[0] == 'imeta' %}
{% for tag in event.tags %} {% set imageUrl = null %}
{% if tag[0] == 'imeta' %} {% set mimeType = null %}
{% set imageUrl = null %} {% set blurhash = null %}
{% set mimeType = null %} {% set dimensions = null %}
{% set blurhash = null %} {% set altText = null %}
{% set dimensions = null %} {% set fallbacks = [] %}
{% set altText = null %} {% set annotatedUsers = [] %}
{% set fallbacks = [] %} {# Parse imeta tag parameters #}
{% set annotatedUsers = [] %} {% for i in 1..(tag|length - 1) %}
{# Parse imeta tag parameters #} {% set param = tag[i] %}
{% for i in 1..(tag|length - 1) %} {% if param starts with 'url ' %}
{% set param = tag[i] %} {% set imageUrl = param[4:] %}
{% if param starts with 'url ' %} {% elseif param starts with 'm ' %}
{% set imageUrl = param[4:] %} {% set mimeType = param[2:] %}
{% elseif param starts with 'm ' %} {% elseif param starts with 'blurhash ' %}
{% set mimeType = param[2:] %} {% set blurhash = param[9:] %}
{% elseif param starts with 'blurhash ' %} {% elseif param starts with 'dim ' %}
{% set blurhash = param[9:] %} {% set dimensions = param[4:] %}
{% elseif param starts with 'dim ' %} {% elseif param starts with 'alt ' %}
{% set dimensions = param[4:] %} {% set altText = param[4:] %}
{% elseif param starts with 'alt ' %} {% elseif param starts with 'fallback ' %}
{% set altText = param[4:] %} {% set fallbacks = fallbacks|merge([param[9:]]) %}
{% elseif param starts with 'fallback ' %} {% elseif param starts with 'annotate-user ' %}
{% set fallbacks = fallbacks|merge([param[9:]]) %} {% set annotatedUsers = annotatedUsers|merge([param[14:]]) %}
{% elseif param starts with 'annotate-user ' %} {% endif %}
{% set annotatedUsers = annotatedUsers|merge([param[14:]]) %} {% endfor %}
{% endif %} {# Alt is also own tag #}
{% endfor %} {% for altTag in event.tags %}
{# Alt is also own tag #} {% if altTag[0] == 'alt' %}
{% for altTag in event.tags %} {% set altText = altTag[1] %}
{% if altTag[0] == 'alt' %} {% endif %}
{% set altText = altTag[1] %} {% endfor %}
{% endif %} {% set images = images|merge([{
{% endfor %} 'url': imageUrl,
{% set images = images|merge([{ 'mimeType': mimeType,
'url': imageUrl, 'blurhash': blurhash,
'mimeType': mimeType, 'dimensions': dimensions,
'blurhash': blurhash, 'altText': altText,
'dimensions': dimensions, 'fallbacks': fallbacks,
'altText': altText, 'annotatedUsers': annotatedUsers
'fallbacks': fallbacks, }]) %}
'annotatedUsers': annotatedUsers {% endif %}
}]) %} {% endfor %}
{% endif %}
{% endfor %}
{% if images|length > 0 %} {% if images|length > 0 %}
<div class="gallery-view" data-controller="gallery"> <div class="gallery-view" data-controller="gallery">
<div class="main-image-wrapper"> <div class="main-image-wrapper">
{% set main = images[0] %} {% set main = images[0] %}
<figure class="media"> <figure class="media">
<picture> <picture>
<img src="{{ main.url }}" <img src="{{ main.url }}"
alt="{{ main.altText|default('Picture') }}" alt="{{ main.altText|default('Picture') }}"
@ -203,22 +201,24 @@
{% endfor %} {% endfor %}
</div> </div>
{% endif %} {% endif %}
</figure> </figure>
{# Display annotated users for main image #} {# Display annotated users for main image #}
{% if main.annotatedUsers|length > 0 %} {% if main.annotatedUsers|length > 0 %}
<div class="annotated-users"> <div class="annotated-users">
{% for userAnnotation in main.annotatedUsers %} {% for userAnnotation in main.annotatedUsers %}
{% set parts = userAnnotation|split(':') %} {% set parts = userAnnotation|split(':') %}
{% if parts|length == 3 %} {% if parts|length == 3 %}
<div class="user-tag" data-left="{{ parts[1] }}" data-top="{{ parts[2] }}" style="left: {{ parts[1] }}%; top: {{ parts[2] }}%;"> <div class="user-tag" data-left="{{ parts[1] }}" data-top="{{ parts[2] }}" style="left: {{ parts[1] }}%; top: {{ parts[2] }}%;">
<twig:Molecules:UserFromNpub ident="{{ parts[0] }}" /> <twig:Molecules:UserFromNpub ident="{{ parts[0] }}" />
</div> </div>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div> </div>
{% endif %} {% endif %}
</div>
</div> </div>
</div> {% endif %}
{% endif %} {% endif %}
</div> </div>

Loading…
Cancel
Save