templates/photo/show.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}Картина "{{ photo.title }}" – Николай Макаров{% endblock %}
  3. {% block meta_description %}
  4.   <meta name="description" content="Картина '{{ photo.title }}' от Николая Макарова. {{ photo.description|striptags|slice(0, 160) }}. Прекрасные произведения искусства, доступные к просмотру и покупке.">
  5. {% endblock %}
  6. {% block meta_og %}
  7.   <meta property="og:title" content="Картина '{{ photo.title }}' – Николай Макаров">
  8.   <meta property="og:description" content="Просмотр картины '{{ photo.title }}' от Николая Макарова. {{ photo.description|striptags|slice(0, 160) }}">
  9.   <meta property="og:image" content="{{ asset('photos/' ~ photo.path) }}">
  10.   <meta property="og:type" content="website">
  11.   <meta property="og:url" content="{{ app.request.uri }}">
  12. {% endblock %}
  13. {% block body %}
  14.   <div class="flex flex-col items-center">
  15.     {% if isAdmin %}
  16.       <a href="{{ path('app_admin_index') }}"
  17.          class="mt-2 mb-5 inline-flex items-center justify-center p-5 text-base font-medium text-gray-500 rounded-lg bg-gray-50 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:bg-gray-800 dark:hover:bg-gray-700 dark:hover:text-white"
  18.          aria-label="Вернуться на главную страницу администратора">
  19.         <span class="w-full">Вернуться на главную</span>
  20.       </a>
  21.     {% else %}
  22.       <a href="{{ path('photo_gallery') }}"
  23.          class="mt-2 mb-5 inline-flex items-center justify-center p-5 text-base font-medium text-gray-500 rounded-lg bg-gray-50 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:bg-gray-800 dark:hover:bg-gray-700 dark:hover:text-white"
  24.          aria-label="Вернуться в галерею">
  25.         <span class="w-full">Вернуться в галерею</span>
  26.       </a>
  27.     {% endif %}
  28.     <div class="mb-4 max-w-screen-sm mx-auto">
  29.       <!-- Картинка с открытием модалки -->
  30.       <img
  31.         src="{{ asset('photos/' ~ photo.path) }}"
  32.         class="cursor-pointer mx-auto mb-4 rounded-lg"
  33.         alt="Картина '{{ photo.title }}' от Николая Макарова"
  34.         onclick="openModal('{{ asset('photos/' ~ photo.path) }}', '{{ photo.title }}')"
  35.         aria-label="Просмотр картины '{{ photo.title }}' в увеличенном размере"
  36.       >
  37.       <div class="p-5 rounded-lg bg-white shadow-lg dark:bg-neutral-800">
  38.         <p class="font-bold my-3 text-lg text-gray-800 dark:text-gray-100">Название картины:</p>
  39.         <h1 class="text-xl font-semibold dark:text-gray-200">{{ photo.title }}</h1>
  40.         <p class="font-bold mb-2 text-lg text-gray-800 dark:text-gray-100">Описание:</p>
  41.         <div class="text-gray-700 dark:text-gray-300">
  42.           {{ (photo is defined and photo.description is defined and photo.description ? photo.description : '')
  43.               | replace({ '\\r\\n': '\n' })
  44.               | replace({ '\n\n': '<br><br>' })
  45.               | replace({ '\n': '<br>' })
  46.               | raw
  47.           }}
  48.         </div>
  49.         <p class="font-bold mb-2 text-lg text-gray-800 dark:text-gray-100">Цена:</p>
  50.         <div class="text-gray-700 dark:text-gray-300">{{ photo is defined and photo.price is defined ? photo.price : '' }}</div>
  51.       </div>
  52.     </div>
  53.   </div>
  54.   <!-- Modal -->
  55.   <div class="fixed inset-0 hidden z-50 bg-black bg-opacity-70 flex items-center justify-center"
  56.        onclick="closeModal()"
  57.        aria-hidden="true">
  58.     <div class="relative max-w-3xl w-full bg-white p-4 rounded-lg shadow-lg dark:bg-neutral-900 transform transition-transform duration-300"
  59.          onclick="stopPropagation(event)">
  60.       <button class="absolute top-3 right-3 w-6 h-6 bg-gray-400 rounded-full flex items-center justify-center cursor-pointer transition-transform duration-300 hover:bg-gray-500"
  61.               onclick="closeModal()"
  62.               aria-label="Закрыть изображение">
  63.         <span class="block w-3 h-0.5 bg-white transform rotate-45"></span>
  64.         <span class="block w-3 h-0.5 bg-white transform -rotate-45"></span>
  65.       </button>
  66.       <img class="w-full h-auto max-h-[90vh] rounded-lg object-contain"
  67.            src=""
  68.            alt="Увеличенное изображение картины {{ photo.title }}">
  69.       <p class="mt-4 text-lg text-center font-semibold text-gray-800 dark:text-gray-100 modal-title"></p>
  70.     </div>
  71.   </div>
  72.   <script>
  73.     function openModal(imageSrc, imageTitle) {
  74.       const modal = document.querySelector('.fixed.inset-0');
  75.       const modalImage = modal.querySelector('img');
  76.       const modalTitle = modal.querySelector('.modal-title');
  77.       modalImage.src = imageSrc;
  78.       modalTitle.textContent = imageTitle;
  79.       modal.classList.remove('hidden');
  80.       document.body.style.overflow = 'hidden';
  81.     }
  82.     function closeModal() {
  83.       const modal = document.querySelector('.fixed.inset-0');
  84.       modal.classList.add('hidden');
  85.       document.body.style.overflow = '';
  86.     }
  87.     function stopPropagation(event) {
  88.       event.stopPropagation();
  89.     }
  90.   </script>
  91. {% endblock %}