{% if editmode and editmode_figure_class|default(false) %}
{% set figure_class = editmode_figure_class %}
{% else %}
{% set figure_class = figure_class|default(config.image_module.figure_class|default('')) %}
{% endif %}
{% set image_thumbnail = image_thumbnail|default(config.image_module.image_thumbnail) %}
{% if editmode and editmode_image_class|default(false) %}
{% set image_class = editmode_image_class %}
{% else %}
{% set image_class = image_class|default(config.image_module.image_class|default('')) %}
{% endif %}
{% set caption_class = caption_class|default(config.image_module.caption_class|default('')) %}
{% set caption_contains_html = caption_contains_html|default(config.image_module.caption_contains_html|default(false)) %}
{% set link_href = link_href|default(false) %}
{% set link_target = link_target|default('') %}
{% set image_tag = image_tag|default('image') %}
{% set is_figure = is_figure is defined ? is_figure : true %}
{% set enablePhotoswipe = enable_photoswipe|default(config.enable_photoswipe|default(false)) %}
{% set imageAsset = pimcore_image(image_tag).getImage() %}
{% if editmode or imageAsset %}
{% set title = '' %}
{% set copyright = '' %}
{% if imageAsset %}
{% set title = imageAsset.getMetadata('title') %}
{% if imageAsset.getMetadata('copyright') %}
{% set copyright = '© ' ~ imageAsset.getMetadata('copyright') %}
{% endif %}
{% endif %}
{% if is_figure %}
<figure class="{{figure_class}}">
{% endif %}
{% if link_href and not editmode %}
<a href="{{link_href}}"{% if link_target %} target="{{ link_target }}"{% endif %} data-debug-thumbnail="{{image_thumbnail}}">
{{ pimcore_image(image_tag,{thumbnail:image_thumbnail, imgAttributes:{class:image_class}}) }}
</a>
{% elseif not editmode and enablePhotoswipe %}
<a href="{{ imageAsset.getFullPath() }}" data-image-width="{{imageAsset.getWidth()}}" data-image-height="{{imageAsset.getHeight()}}" data-image-title="{{ title }}" data-image-copyright="{{ copyright }}" target="_blank" data-debug-thumbnail="{{image_thumbnail}}" class="open-photoswipe">
{{ pimcore_image(image_tag,{thumbnail:image_thumbnail, imgAttributes:{class:image_class}}) }}
</a>
{% else %}
{{ pimcore_image(image_tag,{thumbnail:image_thumbnail, imgAttributes:{class:image_class, 'data-debug-thumbnail':image_thumbnail}}) }}
{% endif %}
{% if is_figure and (title or copyright or editmode or pimcore_input( 'imageCaption').getValue()) %}
<figcaption class="{{caption_class}}">
{% if editmode or pimcore_input( 'imageCaption').getValue() %}
{% if not editmode and caption_contains_html %}
{{ pimcore_input( 'imageCaption', {placeholder:title ~ ' ' ~ copyright, htmlspecialchars:false})|raw }}
{% else %}
{{ pimcore_input( 'imageCaption', {placeholder:title ~ ' ' ~ copyright}) }}
{% endif %}
{% else %}
{{ title }}
{% if copyright %}
<small>{{ copyright }}</small>
{% endif %}
{% endif %}
</figcaption>
{% endif %}
{% if imageAsset %}
{% do pimcore_head_meta().appendProperty('og:image',app.request.getSchemeAndHttpHost() ~ imageAsset.getThumbnail('share_image').getPath()) %}
{% endif %}
{% if is_figure %}
</figure>
{% endif %}
{% endif %}