mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
lightbox on post body images too
This commit is contained in:
parent
f4ff75f88f
commit
87608686eb
1 changed files with 20 additions and 0 deletions
|
@ -34,6 +34,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||||
setupAddPollChoice();
|
setupAddPollChoice();
|
||||||
setupShowElementLinks();
|
setupShowElementLinks();
|
||||||
setupLightboxTeaser();
|
setupLightboxTeaser();
|
||||||
|
setupLightboxPostBody();
|
||||||
});
|
});
|
||||||
|
|
||||||
// All elements with the class "showElement" will show the DOM element referenced by the data-id attribute
|
// All elements with the class "showElement" will show the DOM element referenced by the data-id attribute
|
||||||
|
@ -143,6 +144,25 @@ function setupLightboxTeaser() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setupLightboxPostBody() {
|
||||||
|
const images = document.querySelectorAll('.post_body img');
|
||||||
|
images.forEach(function(img) {
|
||||||
|
const parent = img.parentNode;
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = img.src;
|
||||||
|
link.setAttribute('data-caption', img.alt);
|
||||||
|
parent.replaceChild(link, img);
|
||||||
|
link.appendChild(img);
|
||||||
|
});
|
||||||
|
|
||||||
|
baguetteBox.run('.post_body', {
|
||||||
|
fullScreen: false,
|
||||||
|
titleTag: true,
|
||||||
|
async: true,
|
||||||
|
preload: 3
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// fires after all resources have loaded, including stylesheets and js files
|
// fires after all resources have loaded, including stylesheets and js files
|
||||||
window.addEventListener("load", function () {
|
window.addEventListener("load", function () {
|
||||||
setupHideButtons();
|
setupHideButtons();
|
||||||
|
|
Loading…
Add table
Reference in a new issue