custom/plugins/UandiEfbDownloadCenter/src/Resources/views/storefront/component/media/card/box.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/component/product/card/box-minimal.html.twig' %}
  2. {% block component_product_box_content %}
  3.     {% set media = product %}
  4.     {% set link = path('uandi.downloadcenter.restricted', {mediaId: media.id}) %}
  5.     {% set name = media.title ?: media.fileName %}
  6.     {% if media.translated.customFields.emz_salesforce_download_url %}
  7.         {% set link = media.translated.customFields.emz_salesforce_download_url %}
  8.     {% endif %}
  9.     {{ parent() }}
  10. {% endblock %}
  11. {% block component_product_box_image %}
  12.     <div class="product-image-wrapper">
  13.         <a href="{{ link }}"
  14.            title="{{ name }}"
  15.            class="product-image-link is-standard">
  16.             {% if media.mediaType.name === 'IMAGE' and media.url %}
  17.                 {% sw_thumbnails 'product-image-thumbnails' with {
  18.                     media: media,
  19.                     attributes: {
  20.                         'class': 'product-image is-standard',
  21.                         'alt': media.alt ?: name,
  22.                         'title': name
  23.                     },
  24.                 } %}
  25.             {% elseif media.mediaType.name === 'IMAGE' %}
  26.                 <div class="product-image-placeholder">
  27.                     {% sw_icon 'placeholder' style {
  28.                         'size': 'fluid'
  29.                     } %}
  30.                 </div>
  31.             {% else %}
  32.                 <div class="product-image is-standard">
  33.                     {% sw_icon 'placeholder-pdf' style {
  34.                         'size': 'fluid',
  35.                         'namespace': 'UandiEfbDownloadCenter'
  36.                     } %}
  37.                 </div>
  38.             {% endif %}
  39.         </a>
  40.     </div>
  41. {% endblock %}
  42. {% block component_product_box_info %}
  43.     <div class="product-info">
  44.         <a href="{{ link }}"
  45.            class="product-name"
  46.            title="{{ name }}">
  47.             {{ name }}
  48.         </a>
  49.         {% if media.fileExtension %}
  50.             <p class="media-attribute media-attribute-extension">
  51.                 <span class="media-attribute-label">
  52.                     {{ "uandiDownloadCenter.mediaAttributeLabelExtension"|trans|sw_sanitize }}
  53.                 </span>
  54.                 <span class="media-attribute-value">
  55.                     {{ media.fileExtension|upper }}
  56.                 </span>
  57.             </p>
  58.         {% endif %}
  59.         {% if media.fileSize %}
  60.             <p class="media-attribute media-attribute-size">
  61.                 <span class="media-attribute-label">
  62.                     {{ "uandiDownloadCenter.mediaAttributeLabelSize"|trans|sw_sanitize }}
  63.                 </span>
  64.                 <span class="media-attribute-value">
  65.                     {% set sizes = {
  66.                         0: 'B',
  67.                         1000: 'KB',
  68.                         1000000: 'MB',
  69.                         1000000000: 'GB',
  70.                     } %}
  71.                     {% set power = max(sizes|keys|filter(p => media.fileSize >= p)) %}
  72.                     {{ (media.fileSize/power)|round(2) }} {{ sizes[power] }}
  73.                 </span>
  74.             </p>
  75.         {% endif %}
  76.         {% set eventData = {
  77.             trigger: 'click',
  78.             payload: {
  79.                 file_format: media.fileExtension,
  80.                 file_name: name
  81.             }
  82.         } %}
  83.         <a href="{{ link }}"
  84.            class="btn btn-block btn-primary btn-media-download"
  85.            title="{{ "uandiDownloadCenter.downloadAction"|trans|sw_sanitize }}"
  86.            data-trigger-data-layer-push='{{ eventData|json_encode|raw }}'
  87.         >
  88.             {{ "uandiDownloadCenter.downloadAction"|trans|sw_sanitize }}
  89.         </a>
  90.     </div>
  91. {% endblock %}