templates/pages/galerie.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}Galerie - WA BENIN en images{% endblock %}
  3. {% block body %}
  4. <div class="page-header" style="height: 35vh; min-height: 250px; background-image: linear-gradient(rgba(31, 31, 31, 0.8), rgba(31, 31, 31, 0.8)), url('https://images.unsplash.com/photo-1501281668745-f7f57925c3b4?ixlib=rb-4.0.3&auto=format&fit=crop&w=1920&q=80'); margin-bottom: 40px;">
  5. <div class="container fade-up">
  6. <h1 class="page-title">Galerie Média</h1>
  7. <p style="font-size: 1.2rem; color: var(--gold); max-width: 600px; margin: 0 auto;">Revivez les moments forts de nos événements en images et en vidéos.</p>
  8. </div>
  9. </div>
  10. <section class="section-padding" style="padding-top: 0;">
  11. <div class="container">
  12. <!-- Filtres -->
  13. <div style="display: flex; justify-content: center; flex-wrap: wrap; gap: 15px; margin-bottom: 40px;">
  14. <a href="{{ path('app_galerie') }}" class="btn {% if not current_category %}btn-primary{% else %}btn-outline{% endif %}" style="padding: 8px 20px;">Tout voir</a>
  15. {% for cat in categories %}
  16. <a href="{{ path('app_galerie', {category: cat}) }}" class="btn {% if current_category == cat %}btn-primary{% else %}btn-outline{% endif %}" style="padding: 8px 20px;">{{ cat }}</a>
  17. {% endfor %}
  18. </div>
  19. <!-- Masonry Layout -->
  20. <div style="columns: 3 300px; gap: 20px;">
  21. {% for item in images %}
  22. {% set is_youtube = 'youtube.com' in item.image or 'youtu.be' in item.image %}
  23. {% set img_src = item.image %}
  24. {% if item.isVideo and is_youtube %}
  25. {% set yt_id = item.image|split('v=')|last|split('&')|first|split('/')|last %}
  26. {% set img_src = 'https://img.youtube.com/vi/' ~ yt_id ~ '/0.jpg' %}
  27. {% endif %}
  28. <div class="fade-up gallery-item" style="margin-bottom: 20px; break-inside: avoid; border-radius: var(--border-radius); overflow: hidden; position: relative; cursor: pointer;" onclick="openLightbox('{{ item.image }}', {{ item.isVideo ? 'true' : 'false' }})">
  29. <img src="{{ img_src }}" alt="{{ item.title }}" style="width: 100%; display: block; transition: transform 0.3s;">
  30. {% if item.isVideo %}
  31. <div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: rgba(244, 180, 0, 0.9); border-radius: 50%; display: flex; align-items: center; justify-content: center;">
  32. <i class="fas fa-play" style="color: #fff; font-size: 1.5rem; margin-left: 5px;"></i>
  33. </div>
  34. {% else %}
  35. <div style="position: absolute; top:0; left:0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); opacity: 0; transition: opacity 0.3s; display: flex; align-items: center; justify-content: center;">
  36. <i class="fas fa-search-plus fa-2x" style="color: #fff;"></i>
  37. </div>
  38. {% endif %}
  39. </div>
  40. {% else %}
  41. <p style="text-align: center; grid-column: 1 / -1;">Aucun média disponible pour le moment.</p>
  42. {% endfor %}
  43. </div>
  44. {% if total_pages > 1 %}
  45. <div style="margin-top: 40px; display: flex; justify-content: center; gap: 10px;">
  46. {% for i in 1..total_pages %}
  47. <a href="{{ path('app_galerie', {page: i, category: current_category}) }}" style="width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; {% if current_page == i %}background: var(--gold); color: #fff; border: none;{% else %}background: #fff; border: 1px solid #ddd; color: var(--black-dark);{% endif %} border-radius: 8px; font-weight: bold;">
  48. {{ i }}
  49. </a>
  50. {% endfor %}
  51. </div>
  52. {% endif %}
  53. </div>
  54. </section>
  55. <style>
  56. /* Hover effect for masonry items */
  57. .gallery-item:hover > img {
  58. transform: scale(1.05);
  59. }
  60. .gallery-item:hover > div:not(.fa-play) {
  61. opacity: 1 !important;
  62. }
  63. </style>
  64. <!-- Lightbox Modal -->
  65. <div id="lightbox" style="display: none; position: fixed; z-index: 9999; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.9); align-items: center; justify-content: center;">
  66. <span onclick="closeLightbox()" style="position: absolute; top: 20px; right: 30px; color: white; font-size: 40px; font-weight: bold; cursor: pointer;">&times;</span>
  67. <div id="lightbox-content" style="max-width: 90%; max-height: 90%; text-align: center;"></div>
  68. </div>
  69. <script>
  70. function openLightbox(url, isVideo) {
  71. const lightbox = document.getElementById('lightbox');
  72. const content = document.getElementById('lightbox-content');
  73. lightbox.style.display = 'flex';
  74. if (isVideo) {
  75. let embedUrl = url;
  76. if (url.includes('youtube.com/watch?v=')) {
  77. embedUrl = url.replace('watch?v=', 'embed/');
  78. } else if (url.includes('youtu.be/')) {
  79. embedUrl = url.replace('youtu.be/', 'youtube.com/embed/');
  80. }
  81. content.innerHTML = `<iframe width="800" height="450" style="max-width: 100%; border: none;" src="${embedUrl}?autoplay=1" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>`;
  82. } else {
  83. content.innerHTML = `<img src="${url}" style="max-width: 100%; max-height: 90vh; border-radius: 8px;">`;
  84. }
  85. }
  86. function closeLightbox() {
  87. document.getElementById('lightbox').style.display = 'none';
  88. document.getElementById('lightbox-content').innerHTML = ''; // Stop video
  89. }
  90. </script>
  91. {% endblock %}