Last active
October 20, 2022 15:07
-
-
Save KZeni/0411c7cdc6c4e05afb7bc8f4ecfbed0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fancybox Lightbox | |
//$('a[href^="#"][href$="-bio"]').attr('data-fancybox', '').attr('data-selectable', 'true').attr('data-type', 'inline'); | |
$('a[href*="youtu.be"],a[href*="youtube.com/watch?v="]').attr('data-fancybox', '').attr('data-width', '1280').attr('data-height', '720'); // Catch links to YouTube videos, but don't catch normal YouTube.com links (links to channel, etc.) Give them a width & height (720p) (while it's then mobile-responsive & also doesn't take up the whole screen [offering its own fullscreen option if they want to see it bigger.]) | |
//$('.event-bio').attr('data-selectable', 'true'); | |
// $('a[href*=".pdf"],a.pdf,.pdf a').each(function () { | |
// // Make PDFs scrollable on mobile devices via PDF.js | |
// if (location.hostname === this.hostname || !this.hostname.length) { | |
// // Make sure the file is being served from an external site (avoid origin issues from trying to load that content via JS) | |
// $(this) | |
// .attr('href', '/wp-content/themes/brit/pdfjs/web/viewer.html?file=' + $(this).attr('href')) | |
// .attr('data-fancybox', '') | |
// .attr('data-type', 'iframe') | |
// .attr('data-selectable', 'true'); | |
// } | |
// }); | |
$('[data-fancybox][data-type="iframe"]').attr('data-fancybox', '').attr('data-selectable', 'true'); | |
$('a[href*=".jpg"],a[href*=".jpeg"],a[href*=".png"],a[href*=".gif"],a[href*=".webp"],a[href*=".heic"],a[href*=".heif"],a[href*=".avif"],a[href*="?gf-signature="]').attr('data-fancybox', 'gallery'); | |
var imageTitle, imageAlt; | |
$('a[href*=".jpg"],a[href*=".jpeg"],a[href*=".png"],a[href*=".gif"],a[href*=".webp"],a[href*=".heic"],a[href*=".heif"],a[href*=".avif"],a[data-fancybox]').each(function () { | |
imageTitle = ''; | |
imageAlt = ''; | |
imageTitle = $(this).find('img').attr('title'); | |
imageAlt = $(this).find('img').attr('alt'); | |
if ($(this).attr('data-caption') === '') { | |
// Don't replace existing captions | |
if (typeof imageTitle !== 'undefined' && imageTitle !== '') { | |
$(this).attr('data-caption', imageTitle); | |
} else if (typeof imageAlt !== 'undefined' && imageAlt !== '') { | |
$(this).attr('data-caption', imageAlt); | |
} | |
} | |
}); | |
$.fancybox.defaults.loop = true; | |
$.fancybox.defaults.animationEffect = 'zoom'; | |
$.fancybox.defaults.transitionEffect = 'tube'; | |
$.fancybox.defaults.buttons = ['zoom', 'share', 'slideShow', 'fullScreen', 'download', 'thumbs', 'close']; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment