2019-05-21 19:50:29 +00:00
|
|
|
import $ from 'jquery'
|
|
|
|
import mediumZoom from 'medium-zoom'
|
|
|
|
import fitvids from 'fitvids'
|
|
|
|
|
|
|
|
$(document).ready(() => {
|
|
|
|
fitvids('.js-post-content')
|
|
|
|
|
|
|
|
function adjustImageGallery() {
|
|
|
|
const images = document.querySelectorAll('.kg-gallery-image img')
|
|
|
|
|
|
|
|
for (var i = 0, len = images.length; i < len; i++) {
|
|
|
|
const container = images[i].closest('.kg-gallery-image')
|
|
|
|
const width = images[i].attributes.width.value
|
|
|
|
const height = images[i].attributes.height.value
|
|
|
|
const ratio = width / height
|
|
|
|
container.style.flex = `${ratio} 1 0%`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
adjustImageGallery()
|
|
|
|
|
|
|
|
$('.js-post-content').find('figure img').each(function() {
|
|
|
|
$(this).addClass('js-zoomable')
|
|
|
|
|
|
|
|
const $figcaption = $(this).parent().find('figcaption')
|
|
|
|
if ($figcaption) {
|
|
|
|
$(this).attr('alt', $figcaption.text())
|
|
|
|
} else {
|
2019-08-13 19:49:04 +00:00
|
|
|
$(this).attr('alt', '')
|
2019-05-21 19:50:29 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
mediumZoom('.js-zoomable')
|
|
|
|
})
|