User:Ricordisamoa/HiResThumbs.js

Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
/* <nowiki>
 * HiResThumbs.js by [[User:Ricordisamoa]]
 * uses jQuery
 * replaces the low-resolution thumbs, generated by MediaWiki, with the corresponding full-resolution images
 * also replaces the PNG thumbs of SVG files with the SVG images themselves
 * (a recent browser is needed to scale the images properly)
 * best suited for 'deep zooming' on pages (tablets, etc.)
*/
/* global $, mw */
$( document ).ready( function () {
	'use strict';

	if ( mw.config.get( 'wgPageName' ) !== 'Commons:Quality_images_candidates/candidate_list' ) {
		$( 'img[width][height]' )
		.each( function ( i,e ) {
			$( e ).attr( 'src',
				$( e ).attr( 'src' )
				.replace( /\/thumb\/([a-z0-9])/, '/$1' )
				.replace( /\/[0-9]+px\-.+$/, '' )
			);
		} );
	}
} );
/* </nowiki> */