SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/views/image_gallery_tall_slider.php

  1. <?php
  2. /*
  3.  * kate: tab-width 4; indent-width 4; space-indent on; word-wrap off; word-wrap-column 120;
  4.  * :tabSize=4:indentSize=4:noTabs=true:wrap=false:maxLineLen=120:mode=php:
  5.  *
  6.  * Copyright (C) 2015 Karmabunny Pty Ltd.
  7.  *
  8.  * This file is a part of SproutCMS.
  9.  *
  10.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  11.  * of the GNU General Public License as published by the Free Software Foundation, either
  12.  * version 3 of the License, or (at your option) any later version.
  13.  *
  14.  * For more information, visit <http://getsproutcms.com>.
  15.  */
  16.  
  17. use Sprout\Helpers\Enc;
  18. use Sprout\Helpers\File;
  19. use Sprout\Helpers\Needs;
  20.  
  21.  
  22. Needs::fileGroup('magnific_popup');
  23. Needs::fileGroup('slick');
  24. Needs::fileGroup('image_gallery_slider');
  25.  
  26. // Create unique identifier to allow multiple on a page
  27. $unique = md5(microtime(true));
  28. ?>
  29.  
  30. <?php if (!empty($images) and count($images) > 0): ?>
  31. <ul class="image-gallery-slider js--<?php echo Enc::html($unique); if ($captions): ?> image-gallery-has-captions<?php endif; ?>">
  32. <?php foreach ($images as $image): ?>
  33. <?php if (!empty($image['filename']) and File::exists($image['filename'])): ?>
  34. <li class="image-gallery-slider__item">
  35. <a href="<?php echo Enc::html(File::resizeUrl($image['filename'], $config['full_size'])); ?>"
  36. <?php if ($captions): ?> title="<?php echo Enc::html($image['name'] . ' - ' . $image['description']); ?>"<?php endif; ?>
  37. class="image-gallery-slider__link gallery-<?php echo Enc::html($unique); ?>">
  38. <img src="<?php echo Enc::html(File::resizeUrl($image['filename'], $config['slider_size'] . '-' . $cropping)) ?>" alt="<?php echo Enc::html($image['name']); ?>">
  39. </a>
  40. <?php if (!empty($captions)): ?>
  41. <p class="image-gallery-caption"><?php echo Enc::html($image['name']); ?></p>
  42. <?php endif; ?>
  43. </li>
  44. <?php endif; ?>
  45. <?php endforeach; ?>
  46. </ul>
  47.  
  48. <script>
  49. $(document).ready(function() {
  50. var unique = '<?php echo Enc::js($unique); ?>';
  51.  
  52. if(jQuery().magnificPopup) {
  53. $('.gallery-<?php echo Enc::js($unique); ?>').magnificPopup({
  54. type: 'image',
  55. gallery: {
  56. enabled: true
  57. }
  58. });
  59. }
  60. if (jQuery().slick) {
  61. $('.image-gallery-slider.js--' + unique).slick({
  62. dots: <?php echo Enc::js(!empty($slider_dots)?'true':'false'); ?>,
  63. arrows: <?php echo Enc::js(!empty($slider_arrows)?'true':'false'); ?>,
  64. autoplay: <?php echo Enc::js(!empty($slider_autoplay)?'true':'false'); ?>,
  65. autoplaySpeed: <?php echo Enc::js($slider_speed * 1000); ?>,
  66. });
  67. }
  68. });
  69. </script>
  70. <?php endif; ?>
  71.