MediaWiki:Common.js: Difference between revisions

OMNIVERSE
No edit summary
Blanked the page
Tag: Blanking
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
// Make image links open the full resolution image directly
 
$(document).ready(function() {
    $('.mw-parser-output a.image').each(function() {
        var $link = $(this);
        var $img = $link.find('img');
       
        if ($img.length) {
            var src = $img.attr('src');
           
            // Convert thumbnail URL to full image URL
            // From: /images/thumb/f/fd/Sunny_Meadows.png/300px-Sunny_Meadows.png
            // To: /images/f/fd/Sunny_Meadows.png
            var fullSrc = src.replace(/\/thumb(\/[^\/]+\/[^\/]+\/)(\d+px-)?(.+)$/, '$1$3');
           
            // Update the link href
            $link.attr('href', fullSrc);
        }
    });
});

Latest revision as of 03:21, 25 January 2026