bundles/Alea/AreabricksBundle/Resources/views/areas/cards-catalogue/view.html.twig line 1

Open in your IDE?
  1. <div class="row catalogues">
  2.     <script>
  3.         function bytesToMB (bytes,decimals) { const megabytes = bytes / 1048576; return Math. round (megabytes * Math. pow (10, decimals)) / Math. pow (10, decimals); }
  4.         const getSize = async (id,link) => {
  5.             const client=new XMLHttpRequest();
  6.             client.open("HEAD",link,true);
  7.             client.send();
  8.             client.onreadystatechange = () => {
  9.                 if (client.readyState === client.HEADERS_RECEIVED) {
  10.                     const contentLength = client.getResponseHeader('Content-Length');
  11.                     const contentLengthMb=bytesToMB(contentLength, 1);
  12.                     document.getElementById(`_download_size_${id}`).innerHTML = contentLengthMb;
  13.                 }
  14.             };
  15.         }
  16.     </script>
  17.     {% set blockCount = pimcore_block('myBlock').count %}
  18.     {% for i in pimcore_block('myBlock').iterator %}
  19.         {% if blockCount > 0 %}
  20.             {% set colClass = 'col-lg-' ~ (12 / blockCount) %}
  21.         {% else %}
  22.             {% set colClass = 'col-lg-6' %}
  23.         {% endif %}
  24.         {% if editmode %}
  25.             {{ pimcore_input('link_text') }}
  26.         {% endif %}
  27.         {%  set link = pimcore_input('link_text') %}
  28.         <a href="{{ link ?: '#' }}" target="_blank" class="col-6 {{ colClass }} col-xl text-center d-flex flex-column align-items-center mb-40 catalogue">
  29.             {% if editmode %}
  30.                 <div class="w-75">
  31.                     {{ pimcore_image("image") }}
  32.                 </div>
  33.             {% else %}
  34.                 {#<img src="{{ pimcore_image("image").getSrc() }}" alt="{{ pimcore_image("image").getAlt() }}" class="w-75"/>#}
  35.                 {{ pimcore_image("image").thumbnail('catalogues_thumbs').html({
  36.                     'pictureAttributes': {
  37.                         'class': ''
  38.                     },
  39.                     'imgAttributes': {
  40.                         'class': 'w-75 h-auto'
  41.                     }
  42.                 }) | raw  }}
  43.             {% endif %}
  44.             <span class="fs-20 fw-bold mb-10">
  45.                 {{ pimcore_input("title",{
  46.                     "width": '100%',
  47.                     "placeholder": "Titolo"
  48.                 }) }}
  49.             </span>
  50.             <span class="fs-16"><i class="fa fa-download me-10"></i>
  51.                 Download (<span id="_download_size_{{ i }}"></span>&nbsp;Mb)
  52.             </span>
  53.         </a>
  54.         <script>
  55.             getSize('{{ i }}','{{ link }}');
  56.         </script>
  57.     {% endfor %}
  58. </div>