Skip to content

Instantly share code, notes, and snippets.

@whistlerbrad
Last active July 17, 2020 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whistlerbrad/207dfe98aca8cd820a438d437f7be9df to your computer and use it in GitHub Desktop.
Save whistlerbrad/207dfe98aca8cd820a438d437f7be9df to your computer and use it in GitHub Desktop.
Grid based lookbook photo gallery
<div class="album">
<img
class="album__artwork"
src=""
alt="Image"
title=""
/>
</div>
/* -- code for image gallery pop-up -- */
// add to the very bottom of theme's javascript file
$(document).ready(function() {
$('img.album__artwork').each(function() {
var currentImage = $(this);
currentImage.wrap("<a class='image-link' title='" + currentImage.attr("title") + "' href='" + currentImage.attr("src") + "'</a>");
});
$('.image-link').magnificPopup({
type: 'image',
verticalFit: true, // Fits image in area vertically
titleSrc: function(item) {
return item.el.attr('title');
},
gallery: {
enabled: true,
preload: [0,2],
navigateByImgClick: true,
arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',
tPrev: 'Previous (Left arrow key)',
tNext: 'Next (Right arrow key)',
tCounter: '<span class="mfp-counter">%curr% of %total%</span>',
showCloseBtn: true
},
overflowY: 'hidden'
});
});
/* - end - */
/* Photo Gallery CSS styles --- Starts here */
.template-page .albums {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
grid-auto-rows: minmax(100px, 1fr);
grid-gap: 20px
}
.template-page .album img {
/* use for round circle image effect */
/* border-radius: 100vh;
border: 1px solid #333; */
}
.template-page .album__artwork {
object-fit: cover;
width: 100%;
height: 100%;
}
.template-page .call-to-action {
animation-name: delay;
display:grid;
justify-content:center;
align-items:center;
grid-template-rows: 120px;
animation-duration: 4.5s;
animation-timing-function: ease-out;
animation-delay: 0s;
}
/* @keyframes delay {
0% {
opacity: 0;
}
50% {
opactiy: 0.5;
}
100% {
opacity: 1;
}
}
*/
.template-page .mfp-content {
max-width: 80vmin !important;
}
.mfp-figure figure { overflow-y: auto !important;}
@media (min-width: 800px) {
.template-page .albums {
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
}
.template-page .mfp-content {
max-width: 60vmin !important;
}
.template-page .call-to-action {
align-items:end;
}
}
/* Photo Gallery CSS styles --- Ends here */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment