मीडियाविकि:Gadget-imagelinks.js

मुक्त ज्ञानकोश विकिपीडिया से

सूचना: यह पृष्ठ सुरक्षित करने बाद, परिवर्तनों को देखने लिए ब्राउज़र का कैश ख़ाली करने की आवश्यकता हो सकती है।

  • मोज़िला / फ़ायरफ़ॉक्स / सफ़ारी: shift hold करें जब आप reload क्लिक करते है, या Ctrl-Shift-R (अपल मैक में Cmd-Shift-R) दबाएँ;
  • गूगल क्रोम: Ctrl-shift-R (मैक में Cmd-Shift-R) दबाएँ
  • इंटरनेट एक्सप्लोरर: Ctrl hold करें जब आप refresh क्लिक करते हैं, या Ctrl-F5 क्लिक करते हैं;
  • कॉङ्करर: सिर्फ़ Reload बटन पर क्लिक करें, या F5 क्लिक करें;
  • ऑपरा सदस्य को Tools→Preferences में सम्पूर्ण कैश ख़ाली करने की ज़रूरत हो सकती है।
/*  _____________________________________________________________________________
 * |                                                                             |
 * |                    === WARNING: GLOBAL GADGET FILE ===                      |
 * |                  Changes to this page affect many users.                    |
 * | Please discuss changes on the talk page or on [[WT:Gadget]] before editing. |
 * |_____________________________________________________________________________|
 *
 * From [[:en:MediaWiki:Gadget-imagelinks.js]]
 * Direct imagelinks to Commons
 * Files hosted at Commons have local image links redirected to Commons.
 * Imported from version 9 as of 2012-12-08
 *
 * @source mediawiki.org/wiki/Snippets/Direct_imagelinks_to_Commons
 * @author [[commons:User:Krinkle]]
 * @version 9
 */
if ( mw.config.get( 'wgNamespaceNumber', 0 ) >= 0 ) {
	$( function () {
		var
			uploadBaseRe = /^\/\/upload\.wikimedia\.org\/wikipedia\/commons/,
 
			localBasePath = new RegExp('^' + mw.util.getUrl( mw.config.get( 'wgFormattedNamespaces' )['6'] + ':' ).replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&")),
			localBaseScript = new RegExp('^' + (mw.util.wikiScript() + '?title=' + mw.util.wikiUrlencode( mw.config.get( 'wgFormattedNamespaces' )['6'] + ':' )).replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&")),
 
			commonsBasePath =  '//commons.wikimedia.org/wiki/File:',
			commonsBaseScript =  '//commons.wikimedia.org/w/index.php?title=File:';
 
		$( 'a.image, a.mw-file-description' ).attr( 'href', function ( i, currVal ) {
			if ( uploadBaseRe.test( $(this).find( 'img' ).attr( 'src' ) ) ) {
				return currVal
					.replace( localBasePath, commonsBasePath )
					.replace( localBaseScript, commonsBaseScript );
			}
		});
	});
}