Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container">

  <div class="post-gallery">
    <a href="https://images.unsplash.com/photo-1578329738289-c388f525e57b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1920&h=1080&q=60" class="js-modaal-gallery" data-modaal-desc="Backpacking through an autumn fall" data-group="gallery-1" data-slick-modal-gallery="1" data-modaal-scope="modaal_1" data-gallery-active="is_active">
      <img src="https://images.unsplash.com/photo-1578329738289-c388f525e57b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1280&h=720&q=60" alt="Backpacking through an autumn fall">
    </a>
    <a href="https://images.unsplash.com/photo-1578332882789-0a08fbb9630f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=600&h=1067&q=60" class="js-modaal-gallery" data-modaal-desc="Standing on top of the world" data-group="gallery-1" data-slick-modal-gallery="1" data-modaal-scope="modaal_2">
      <img src="https://images.unsplash.com/photo-1578332882789-0a08fbb9630f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=540&h=960&q=60" alt="Standing on top of the world">
    </a>
    <a href="https://images.unsplash.com/photo-1578272662071-f536c2e2610d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=723&h=1083&q=60" class="js-modaal-gallery" data-modaal-desc="Neon lights, guide me home" data-group="gallery-1" data-slick-modal-gallery="1" data-modaal-scope="modaal_3">
      <img src="https://images.unsplash.com/photo-1578272662071-f536c2e2610d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=540&h=960&q=60" alt="Neon lights, guide me home">
    </a>
  </div><?php // .post-gallery ?>

</div><?php // .container ?>


<?php // This is the function for wordpress to override the standard core gallery - it will likely need some dev love with each project ?>

<!-- 

if ( ! function_exists('updated_gallery_shortcode'))
{
    /**
     * Update core Gallery shortcode
     *
     * @param $attr
     * @return string
     */
    function updated_gallery_shortcode($attr)
    {

        $random_token = random_alphanumeric_string( 10 );

        $post = get_post();

        static $instance = 0;
        $instance++;

        if (empty($attr['ids']))
        {
            return '';
        }

        $include = $attr['ids'];

        $post_in = explode(',', $include);

        $_attachments = get_posts(array(
            //'include' => $include,
            'post__in' => $post_in,
            'post_status' => 'inherit',
            'post_type' => 'attachment',
            'post_mime_type' => 'image',
            //'order' => 'ASC',
            //'orderby' => 'menu_order ID',
            'orderby' => 'post__in',
            'posts_per_page' => '-1'
        ));

        $attachments = array();

        foreach ($_attachments as $key => $val)
        {
            $attachments[$val->ID] = $_attachments[$key];
        }

        if (empty($attachments))
        {
            return '';
        }

        $output = '';
        $thumbs = array();
        $medium_imgs = array();
        $first = TRUE;

        foreach ($attachments as $id => $attachment)
        {

            $image_arr_large = wp_get_attachment_image_src($id, 'panel-image-med-2x');
            $image_arr_medium = wp_get_attachment_image_src($id, 'content-gallery');
            $image_arr_small = wp_get_attachment_image_src($id, 'google-panel-image');

            if (
                isset($image_arr_large[0])
                && ! empty($image_arr_large[0])
                && isset($image_arr_medium[0])
                && ! empty($image_arr_medium[0])
                && isset($image_arr_small[0])
                && ! empty($image_arr_small[0])
            )
            {

                $image_meta = wp_get_attachment_metadata($id);

                $thumbs[] = '<div class="thumb" style="background-image: url(' . $image_arr_small[0] . ');"></div>';

                $caption = $attachment->post_excerpt;

                if ($first)
                {
                    $first_caption = $caption;
                    $first = FALSE;
                }

                $medium_imgs[] = '<div><a href="' . $image_arr_large[0] . '" data-barba-prevent="self" data-group="gallery-' . $random_token . '" class="js-modaal--gallery" data-slick-modal-gallery="' . $random_token . '" data-modaal-desc="' . h( $caption ) . '"><img src="' . $image_arr_medium[0] . '" alt="' . $caption . '" /></a><div class="caption"><p>' . $caption . '</p></div></div>';

            }
        }

        ob_start();
        ?>

        <div class="cms-block--gallery">

            <div class="cms-block--gallery__main" data-slick-modal-gallery="<?= $random_token ?>">

                <?php

                // TODO: Update this to solve issue when gallery contains less than 5 images, this is a quick fix

                echo implode('', $medium_imgs);

                /*
                if (count($medium_imgs) <= 2)
                {

                    echo implode('', $medium_imgs);
                    echo implode('', $medium_imgs);
                } else
                {
                    if (count($medium_imgs) <= 5)
                    {

                        echo implode('', $medium_imgs);
                    }
                }
                */
                ?>

            </div><!-- .cms-block-gallery_main -->

            <nav class="cms-block--gallery__thumbs">
                <?php

                echo implode('', $thumbs);

                if (count($thumbs) <= 2)
                {

                    echo implode('', $thumbs);
                    echo implode('', $thumbs);
                } else
                {
                    if (count($thumbs) <= 5)
                    {

                        echo implode('', $thumbs);
                    }
                }
                ?>
            </nav><!-- .cms-block-gallery_thumbs -->

        </div><!-- post-gallery -->

        <?php
        $container = ob_get_contents();
        ob_end_clean();

        $output .= $container;

        return $output;
    }

    remove_shortcode('gallery', 'gallery_shortcode'); // removes the original shortcode
    add_shortcode('gallery', 'updated_gallery_shortcode'); // add your own shortcode
} -->
              
            
!

CSS

              
                // Base imported from UI-base codepen - Includes common variables.
 
.container {
  margin: 0 auto;
  max-width: 900px;
  display: block;
}

// TODO: Add reduced motion support.

// ------------------------------
// Post gallery
// ------------------------------

.post-gallery {
  // ------------------------------
  // Variables for styles
  // ------------------------------

  $brand-primary:		#d03838;
  $border-color: #ebebeb;
  $grey-mid: #888888;
  $grey-light: #cccccc;
  $grey-dark: #222222;
  $spacing: 60px;

  a {
    width: 100%;
    display: flex!important; // Override any inline slick display block attributes
    align-items: center;
    justify-content: center;
    background-color: $grey-dark;

    img {
      width: auto;
      height: auto;
      max-width: 100%;
      max-height: 100%;
    }
  }

  .slick-arrow {
    padding: 0; 
  }

  .slick-prev,
  .slick-next {
    position: absolute;
    top: 50%;
    z-index: 10;
    width: 60px;
    height: 60px;
    margin-top: -30px;
    padding: 0;
    display: block;
    background-color: $brand-primary;
    color: white;
    border-radius: 50%;

    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;

    &.slick-disabled {
      display: none!important;
    }

    svg {
      width: 25px;
      height: 8px;
      transition: transform $timing $ease-std;
    }
  }
  .slick-prev {
    left: 20px;

    @include hover() {
      svg { transform: translateX(-2px); }
    }
  }
  .slick-next {
    right: 20px;

    @include hover() {
      svg { transform: translateX(2px); }
    }
  }

  .slick-dots {
    list-style: none;
    margin: $spacing/4 0;
    padding: 0;
    color: $grey-mid;
    font-size: 1.6rem;
    margin: $spacing/4 0;

    strong {
      color: $brand-primary;
      margin-right: 10px;
    }

    li:not(.slick-active) {
      display: none;
    }
  }
}
              
            
!

JS

              
                // Sliders
// ------------------------------------------------------------


var slick_sliders = [
	{
		selector: '.post-gallery',
		limit: null,
		operator: null,
		args: {
			slidesToShow: 1,
			slidesToScroll: 1,
			infinite: false,
			fade: true,
			accessibility: false,
			arrows: true,
			dots: true,
			adaptiveHeight: true,
			swipe : false,
      rows: 0,
			prevArrow: '<button type="button" class="slick-prev" aria-label="Previous image (use left arrow to change)"><span class="hidden">Prev Image</span><svg xmlns="http://www.w3.org/2000/svg" width="25" height="8" viewBox="0 0 25 8"><path fill="#fff" d="M25 3H6V0L0 4l6 4V5h19z"/></svg></button>',
			nextArrow: '<button type="button" class="slick-next" aria-label="Next image (use right arrow to change)"><span class="hidden">Next Image</span><svg xmlns="http://www.w3.org/2000/svg" width="25" height="8" viewBox="0 0 25 8"><path fill="#fff" d="M25 4l-6-4v3H0v2h19v3z"/></svg></button>',
			customPaging: function(slider, i) {
				var caption = $(slider.$slides[i]).data('modaal-desc');
				i++;
				return '<strong>'+i+' of '+slider.slideCount+'</strong>'+caption;
			}
		}
	}
];

var operators = {
	'<': function(a, b) { return a < b },
	'>': function(a, b) { return a > b },
	'<=': function(a, b) { return a <= b },
	'>=': function(a, b) { return a >= b },
	'==': function(a, b) { return a == b }
}

function slick_init(sliders) {
	
	var window_width = jQuery(window).width();
	
	jQuery.each(sliders, function(index, value){
		
		if (jQuery(value.selector).length > 0) {
			
			if (typeof(value.limit) === 'undefined' || value.limit == null) {
				
				if (!jQuery(value.selector).hasClass('slick-initialized')) {
					jQuery(value.selector).slick(value.args);
				}
			}
			else {
				
				if (operators[value.operator](window_width, value.limit)) {
					
					if (!jQuery(value.selector).hasClass('slick-initialized')) {
						jQuery(value.selector).slick(value.args);
					}
					
				}
				else {
					
					if (jQuery(value.selector).hasClass('slick-initialized')) {
						jQuery(value.selector).slick('unslick');
					}
					
				}
				
			}			
			
		}
		
	});
	
}

jQuery(document).ready(function(){
	
	slick_init(slick_sliders);
	
	// Resize functions
	jQuery(window).resize(function(){
		slick_init(slick_sliders);
	});
  
  $('.js-modaal-gallery').modaal({ type: 'image' });
	
});
              
            
!
999px

Console