fix old images
This commit is contained in:
@@ -811,10 +811,18 @@
|
||||
|
||||
/* ------------------------- Click on small articles ------------------------ */
|
||||
|
||||
$('article.home-small').click(function () {
|
||||
let href = $(this).children('a.thumbnailwrapper').attr("href")
|
||||
window.open(href, "_self")
|
||||
})
|
||||
// $('article.home-small').click(function () {
|
||||
// let href = $(this).children('a.thumbnailwrapper').attr("href")
|
||||
// window.open(href, "_self")
|
||||
// })
|
||||
|
||||
|
||||
$(document).on({
|
||||
mouseup: function () {
|
||||
let href = $(this).children('a.thumbnailwrapper').attr("href")
|
||||
window.open(href, "_self")
|
||||
}
|
||||
}, 'article.home-small');
|
||||
|
||||
/* ------------------------------ hover on home ----------------------------- */
|
||||
|
||||
@@ -1032,19 +1040,50 @@
|
||||
/* SINGLE */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
jQuery.fn.changeTag = function (newTag) {
|
||||
var q = this;
|
||||
this.each(function (i, el) {
|
||||
var h = "<" + el.outerHTML.replace(/(^<\w+|\w+>$)/g, newTag) + ">";
|
||||
try {
|
||||
el.outerHTML = h;
|
||||
} catch (e) { //elem not in dom
|
||||
q[i] = jQuery(h)[0];
|
||||
}
|
||||
|
||||
});
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
if (isSingle) {
|
||||
|
||||
/* ---------------------------- wrap figcaptions --------------------------- */
|
||||
|
||||
|
||||
$("figcaption").wrapInner("<span></span>")
|
||||
|
||||
|
||||
|
||||
/* ----------------------------- images, gallery ---------------------------- */
|
||||
|
||||
//hide caption on desktop
|
||||
//wrap old galleries
|
||||
$('.single-content>p').each(function () {
|
||||
let nrOfImgs = $(this).children('img').length
|
||||
if (nrOfImgs > 1) {
|
||||
$(this).addClass('wp-block-gallery')
|
||||
} else if (nrOfImgs == 1) {
|
||||
$(this).addClass('wp-block-image')
|
||||
}
|
||||
})
|
||||
|
||||
//wrap images on old posts
|
||||
$('.single-content div.wp-caption img, .single-content>.wp-block-image>img, .single-content>.wp-block-gallery>img').each(function () {
|
||||
let src = $(this).attr('src')
|
||||
$(this).wrap('<a class="cb-gallery" href="' + src + '" ></a>')
|
||||
// $(this).parent('p').addClass('wp-block-image')
|
||||
})
|
||||
|
||||
//change figcaption tag on old posts
|
||||
$('.single-content div.wp-caption .wp-caption-text').changeTag("figcaption")
|
||||
|
||||
|
||||
//wrap figcaptions
|
||||
$("figcaption").wrapInner("<span></span>")
|
||||
|
||||
//hover on images on desktop
|
||||
if (!isMobile) {
|
||||
$('.wp-block-gallery .blocks-gallery-item, .wp-block-image').hover(function () {
|
||||
$(this).find("figcaption").addClass("vis")
|
||||
|
||||
Reference in New Issue
Block a user