مدیاویکی:Common.js: تفاوت میان نسخهها
از ویکییاد
جز «مدیاویکی:Common.js» را محافظت کرد ([ویرایش=تنها مدیران] (بیپایان) [انتقال=تنها مدیران] (بیپایان)) |
بدون خلاصۀ ویرایش |
||
| خط ۱: | خط ۱: | ||
/* | /** | ||
* Gallery boxes: use the image as full-cover background instead of <img> tag | |||
* Runs after page is loaded | |||
document.addEventListener('DOMContentLoaded', function() { | */ | ||
document.addEventListener('DOMContentLoaded', function () { | |||
document.querySelectorAll('.gallerybox').forEach(function (box) { | |||
// Find the <img> inside this box | |||
const img = box.querySelector('img.mw-file-element'); | |||
if (img && img.src) { | |||
// Set background using the exact src of the thumbnail | |||
box.style.backgroundImage = 'url(' + img.src + ')'; | |||
box.style.backgroundSize = 'cover'; | |||
box.style.backgroundPosition = 'center center'; | |||
box.style.backgroundRepeat = 'no-repeat'; | |||
// Hide the original <img> tag | |||
img.style.display = 'none'; | |||
} | |||
}); | |||
}); | }); | ||
نسخهٔ ۲۳ ژانویهٔ ۲۰۲۶، ساعت ۱۹:۳۴
/**
* Gallery boxes: use the image as full-cover background instead of <img> tag
* Runs after page is loaded
*/
document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('.gallerybox').forEach(function (box) {
// Find the <img> inside this box
const img = box.querySelector('img.mw-file-element');
if (img && img.src) {
// Set background using the exact src of the thumbnail
box.style.backgroundImage = 'url(' + img.src + ')';
box.style.backgroundSize = 'cover';
box.style.backgroundPosition = 'center center';
box.style.backgroundRepeat = 'no-repeat';
// Hide the original <img> tag
img.style.display = 'none';
}
});
});
