{% fragment render(widget = {}, options = {}, manager = {}, contextOptions = {}) %} {%- set attachment = apos.image.first(widget._image) -%} {%- if widget.aposPlaceholder and manager.options.placeholderUrl -%} {{ __t('apostrophe:imagePlaceholder') }} {%- elif attachment -%} {%- set className = options.className or manager.options.className -%} {{ _imageWithLink(widget, attachment, options, manager, contextOptions) -}} {% if widget.caption -%}
{{ widget.caption }}
{% endif %} {%- endif -%} {% endfragment %} {%- macro _imageWithLink(widget, attachment, options, manager, contextOptions) -%} {%- if not widget.linkTo or widget.linkTo === 'none' -%} {{- _image(attachment, options, manager, contextOptions) -}} {%- else -%} {{- _link(widget, attachment, options, manager, contextOptions) -}} {%- endif -%} {%- endmacro -%} {% macro _image(attachment, options, manager, contextOptions) %} {%- set className = options.className or manager.options.className -%} {%- set dimensionAttrs = options.dimensionAttrs or manager.options.dimensionAttrs -%} {%- set loadingType = options.loadingType or manager.options.loadingType -%} {%- set size = options.size or manager.options.size or 'full' -%} {% endmacro %} {% macro _link(widget, attachment, options, manager, contextOptions) %} {%- set className = options.className or manager.options.className -%} {{ _image(attachment, options, manager, contextOptions) }} {% endmacro %} {% macro _url(widget) %} {% set type = widget.linkTo %} {% set name = '_' + apos.util.slugify(type) %} {% set item = widget[name][0] %} {% if type === '_url' %} {{- widget.linkHref -}} {% else %} {{- item._url -}} {% endif %} {% endmacro %} {% macro _title(widget) %} {% set name = '_' + apos.util.slugify(widget.linkTo) %} {% set item = widget[name][0] %} {% if widget.linkTo === '_url' %} {{- widget.linkHrefTitle or widget.caption -}} {% else %} {{- widget.linkTitle or item.title -}} {% endif %} {% endmacro %} {% macro _figureStyle(options, manager) %} {%- if options.inlineStyles === true -%}margin: 0; {%- elif options.inlineStyles !== false and manager.options.inlineStyles === true -%}margin: 0; {%- endif -%} {% endmacro %}