{% block artgris_media_widget %} {% import _self as artgris %} {% apply spaceless %} {{ artgris.render_media(form, false, form.vars.id, conf) }} {% endapply %} {% include '@ArtgrisMedia/form/_modal.html.twig' %} {% include '@ArtgrisMedia/form/_crop_modal.html.twig' with {crop_options: form.vars.crop_options} %} {% endblock %} {% block artgris_media_collection_widget %} {% import _self as artgris %} {% apply spaceless %} {% if prototype is defined %} {% set attr = attr|merge({'data-prototype': artgris.render_media(prototype, true, form.vars.id, conf)}) %} {% set attr = attr|merge({'data-prototype-name': prototype.vars.name}) %} {% endif %} {% set attr = attr|merge({'data-allow-add': allow_add ? 1 : 0}) %} {% set attr = attr|merge({'data-max': data_max ? data_max : 100}) %} {% set attr = attr|merge({'data-min': data_min ? data_min : 0}) %} {% set attr = attr|merge({'data-init-with-n-elements': data_init_with_n_elements ? data_init_with_n_elements : 1}) %} {% set attr = attr|merge({'data-add-at-the-end': data_add_at_the_end ? data_add_at_the_end : false}) %} {% set attr = attr|merge({'data-allow-remove': allow_delete ? 1 : 0 }) %} {% set attr = attr|merge({'data-name-prefix': full_name}) %}
{% for media in form %} {{ artgris.render_media(media, true, form.vars.id, conf) }} {% endfor %}
{% include '@ArtgrisMedia/form/_modal.html.twig' %} {% include '@ArtgrisMedia/form/_crop_modal.html.twig' with {crop_options: form.vars.prototype.vars.crop_options} %} {% endapply %} {% endblock %} {% macro render_media(form, collection = true, id, conf) %} {% apply spaceless %}
{% if collection %}
{% endif %} {% set base_path = get_web_path(conf) %} {% set hotspot = false %} {% if form.vars.attr is defined and form.vars.attr is iterable and form.vars.attr.typemedia is defined and form.vars.attr.typemedia == "hotspot" %} {% set hotspot = true %} {% endif %} {% if not hotspot %}
{% set preview = fileIcon(form.vars.data).html %} {% if form.vars.allow_crop and ' {{ preview|raw }} {% else %} {{ preview|raw }} {% endif %}
{% endif %} {% block fields %} {#label + input#}
{% endblock %} {% if collection %}
{% include '@ArtgrisMedia/form/_btn_manager.html.twig' with {'id' : id, 'form' : form, 'conf': conf} only %}
{% else %}
{% include '@ArtgrisMedia/form/_btn_manager.html.twig' with {'id' : id, 'form' : form, 'conf': conf, 'collection': false} only %}
{% endif %} {% if collection %} {% endif %}
{% if hotspot %}
{% set dataExplode = form.vars.name|split("-_-") %} {% set counter = dataExplode[1] %} {% set preview = fileIcon(form.vars.data).html %} {% set nameComponentHotspots = form.vars.name ~ "_content" %} {% set valueHotspots = form.parent.children[nameComponentHotspots].vars.value %} {% if 'img' in preview %} {{ preview|raw }} {% endif %}
{{ valueHotspots|raw }}
{% endif %} {% if collection and form.vars.errors|length > 0 %}
{{ form_errors(form) }}
{% endif %}
{% endapply %} {% endmacro %}