Files
Grav-Admin-Plugin/themes/grav/templates/forms/fields/file/file.html.twig
Flavio Copes b76b79e611 Improve File input field for Admin
Add removing files from a blueprint to Admin, moved from Pro. Drop
`showuploaded`, `ispluginconfig`, `showuploadedpreview` options from
the File field. Added a "blueprint" option to specify the field name
and type, e.g. `plugins.admin` or `themes.antimatter`. Dropped the
multiple option, as it'd need more handling that now it's not there.
2015-12-21 16:22:04 +01:00

30 lines
1.5 KiB
Twig

{% extends "forms/field.html.twig" %}
{% set defaults = config.plugins.form %}
{% set files = defaults.files|merge(field|default([])) %}
{% block input %}
{% if not plugin and not theme %}
The "file" input field cannot be used in Pages Blueprints. It's intended to be used for Plugins and Themes blueprints.
Use the "pagemediaselect" type instead.
{% else %}
{% if value %}
<img src="{{ base_url_relative_frontend == '/' ? '/' : base_url_relative_frontend ~ '/'}}{{ value }}" alt="{{ value|replace({(files.destination ~ '/'): ''}) }}" />
<a href="{{ uri.addNonce(base_url_relative ~ '/media/' ~ base64_encode(base_path ~ '/' ~ value) ~ '/task' ~ config.system.param_sep ~ 'removeFileFromBlueprint' ~ '/blueprint' ~ config.system.param_sep ~ files.blueprint ~ '/field' ~ config.system.param_sep ~ files.name ~ '/redirect' ~ config.system.param_sep ~ base64_encode(uri.path), 'admin-form', 'admin-nonce') }}">
<i class="fa fa-close"></i>
</a>
{% endif %}
<div class="form-input-wrapper {{ field.size }}">
<input
{# required attribute structures #}
name="{{ (scope ~ field.name)|fieldName ~ '[]' }}"
{% block input_attributes %}
type="file"
{% if files.accept %}accept="{{ files.accept|join(',') }}"{% endif %}
{{ parent() }}
{% endblock %}
/>
</div>
{% endif %}
{% endblock %}