{% sw_extends '@Storefront/storefront/component/product/card/box-minimal.html.twig' %}
{% block component_product_box_content %}
{% set media = product %}
{% set link = path('uandi.downloadcenter.restricted', {mediaId: media.id}) %}
{% set name = media.title ?: media.fileName %}
{% if media.translated.customFields.emz_salesforce_download_url %}
{% set link = media.translated.customFields.emz_salesforce_download_url %}
{% endif %}
{{ parent() }}
{% endblock %}
{% block component_product_box_image %}
<div class="product-image-wrapper">
<a href="{{ link }}"
title="{{ name }}"
class="product-image-link is-standard">
{% if media.mediaType.name === 'IMAGE' and media.url %}
{% sw_thumbnails 'product-image-thumbnails' with {
media: media,
attributes: {
'class': 'product-image is-standard',
'alt': media.alt ?: name,
'title': name
},
} %}
{% elseif media.mediaType.name === 'IMAGE' %}
<div class="product-image-placeholder">
{% sw_icon 'placeholder' style {
'size': 'fluid'
} %}
</div>
{% else %}
<div class="product-image is-standard">
{% sw_icon 'placeholder-pdf' style {
'size': 'fluid',
'namespace': 'UandiEfbDownloadCenter'
} %}
</div>
{% endif %}
</a>
</div>
{% endblock %}
{% block component_product_box_info %}
<div class="product-info">
<a href="{{ link }}"
class="product-name"
title="{{ name }}">
{{ name }}
</a>
{% if media.fileExtension %}
<p class="media-attribute media-attribute-extension">
<span class="media-attribute-label">
{{ "uandiDownloadCenter.mediaAttributeLabelExtension"|trans|sw_sanitize }}
</span>
<span class="media-attribute-value">
{{ media.fileExtension|upper }}
</span>
</p>
{% endif %}
{% if media.fileSize %}
<p class="media-attribute media-attribute-size">
<span class="media-attribute-label">
{{ "uandiDownloadCenter.mediaAttributeLabelSize"|trans|sw_sanitize }}
</span>
<span class="media-attribute-value">
{% set sizes = {
0: 'B',
1000: 'KB',
1000000: 'MB',
1000000000: 'GB',
} %}
{% set power = max(sizes|keys|filter(p => media.fileSize >= p)) %}
{{ (media.fileSize/power)|round(2) }} {{ sizes[power] }}
</span>
</p>
{% endif %}
{% set eventData = {
trigger: 'click',
payload: {
file_format: media.fileExtension,
file_name: name
}
} %}
<a href="{{ link }}"
class="btn btn-block btn-primary btn-media-download"
title="{{ "uandiDownloadCenter.downloadAction"|trans|sw_sanitize }}"
data-trigger-data-layer-push='{{ eventData|json_encode|raw }}'
>
{{ "uandiDownloadCenter.downloadAction"|trans|sw_sanitize }}
</a>
</div>
{% endblock %}