{% macro bytesToSize(bytes) -%}
    {% spaceless %}
        {% set kilobyte = 1024 %}
        {% set megabyte = kilobyte * 1024 %}
        {% set gigabyte = megabyte * 1024 %}
        {% set terabyte = gigabyte * 1024 %}

        {% if bytes < kilobyte %}
            {{ bytes ~ ' B' }}
        {% elseif bytes < megabyte %}
            {{ (bytes / kilobyte)|number_format(2, '.') ~ ' KB' }}
        {% elseif bytes < gigabyte %}
            {{ (bytes / megabyte)|number_format(2, '.') ~ ' MB' }}
        {% elseif bytes < terabyte %}
            {{ (bytes / gigabyte)|number_format(2, '.') ~ ' GB' }}
        {% else %}
            {{ (bytes / terabyte)|number_format(2, '.') ~ ' TB' }}
        {% endif %}
    {% endspaceless %}
{%- endmacro %}

<ul class="g-list-labels">
    <li>
        <span class="g-file-name">{{ 'GANTRY5_PLATFORM_NAME'|trans }}</span>
        <span class="g-file-size">{{ 'GANTRY5_PLATFORM_SIZE'|trans }}</span>
        <span class="g-file-mtime">{{ 'GANTRY5_PLATFORM_LATEST_MODIFIED'|trans }}</span>
    </li>
</ul>
<ul>
    {% for index,file in files %}
        <li data-file="{{ file|json_encode()|e('html_attr') }}" data-file-url="{{ file.pathname|e }}"{{ file.pathname == value ? ' class="selected"' : '' }}>
            {% if file.isInCustom %}
                <span class="g-file-delete" data-g-file-delete data-dz-remove><i class="fa fa-fw fa-trash-o"></i></span>
            {% endif %}
            {% if file.isImage %}
                <div class="g-thumb g-image g-image-{{ file.extension }}">
                    <div style="background-image: url({{ url(file.pathname) }})"></div>
                </div>
            {% else %}
                <div class="g-thumb">{{ file.extension }}</div>
            {% endif %}

            <span class="g-file-name">{{ file.filename }}</span>
            <span class="g-file-size">{{ _self.bytesToSize(file.size) }}</span>
            <span class="g-file-mtime">{{ file.mtime|date('j M o') }}</span>
        </li>
    {% endfor %}

    {% if files|length == 0 %}
        <li class="no-files-found"><h2>Folder is Empty</h2></li>
    {% endif %}
</ul>
