မီႇတီႇယႃႇဝီႇၶီႇ:Gadget-imagelinks.js: လွင်ႈပႅၵ်ႇပိူင်ႈ ၼႂ်းၵႄႈ လွင်ႈၶူၼ်ႉၶႆႈ
Appearance
Content deleted Content added
ၵေႃႇသၢင်ႈၼႃႈလိၵ်ႈဝႆႉ တင်း "/* _____________________________________________________________________________ * | | * | === WARNING: GLOBAL GADGET FILE === | * | Changes to this page affect many users. | * | Please discuss changes on the talk page or on WT:Gadget before editing. | * |..." |
|||
ထႅဝ် 32: | ထႅဝ် 32: | ||
commonsBaseScript = '//commons.wikimedia.org/w/index.php?title=File:'; |
commonsBaseScript = '//commons.wikimedia.org/w/index.php?title=File:'; |
||
$content.find( 'a.image' ).attr( 'href', function ( i, currVal ) { |
$content.find( 'a.image, a.mw-file-description' ).attr( 'href', function ( i, currVal ) { |
||
if ( uploadBaseRe.test( $( this ).find( 'img' ).attr( 'src' ) ) ) { |
if ( uploadBaseRe.test( $( this ).find( 'img' ).attr( 'src' ) ) ) { |
||
return currVal |
return currVal |
ၵၢၼ်ၶူၼ်ႉၶႆႈ ၵမ်းလိုၼ်းသုတ်း မိူဝ်ႈ 21:25, 7 မၢတ်ႉၶျ် 2023
/* _____________________________________________________________________________
* | |
* | === WARNING: GLOBAL GADGET FILE === |
* | Changes to this page affect many users. |
* | Please discuss changes on the talk page or on [[WT:Gadget]] before editing. |
* |_____________________________________________________________________________|
*
* Direct imagelinks to Commons
*
* Required modules: mediawiki.util
*
* @source https://www.mediawiki.org/wiki/Snippets/Direct_imagelinks_to_Commons
* @author Krinkle
* @version 2015-08-01
*/
if ( mw.config.get( 'wgNamespaceNumber', 0 ) >= 0 ) {
mw.hook( 'wikipage.content' ).add( function ( $content ) {
var
uploadBaseRe = /^\/\/upload\.wikimedia\.org\/wikipedia\/commons/,
localFileNSString = mw.config.get( 'wgFormattedNamespaces' )['6'] + ':',
localBasePath = new RegExp(
'^' + mw.util.escapeRegExp( mw.util.getUrl( localFileNSString ) )
),
localBaseScript = new RegExp(
'^' + mw.util.escapeRegExp(
mw.util.wikiScript() + '?title=' + mw.util.wikiUrlencode( localFileNSString )
)
),
commonsBasePath = '//commons.wikimedia.org/wiki/File:',
commonsBaseScript = '//commons.wikimedia.org/w/index.php?title=File:';
$content.find( '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 );
}
} );
} );
}