Diferencia entre revisiones de «MediaWiki:Gadget-a-commons-directo.js»
Apariencia
Contenido eliminado Contenido añadido
Migration: wikiGetlink → getUrl |
|||
Línea 17: | Línea 17: | ||
commonsBaseScript = '//commons.wikimedia.org/w/index.php?title=File:'; |
commonsBaseScript = '//commons.wikimedia.org/w/index.php?title=File:'; |
||
$( 'a.image' ).attr( 'href', function ( i, currVal ) { |
$( '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 |
Revisión actual - 17:52 7 mar 2023
/**
* Direct imagelinks to Commons
*
* @fuente: //www.mediawiki.org/wiki/Snippets/Direct_imagelinks_to_Commons
* @autor: [[commons:User:Krinkle]]
* @versión: 9
*/
if ( mw.config.get( 'wgNamespaceNumber', 0 ) >= 0 ) {
$( function () {
var
uploadBaseRe = /^\/\/upload\.wikimedia\.org\/wikipedia\/commons/,
localBasePath = mw.util.getUrl( mw.config.get( 'wgFormattedNamespaces' )['6'] + ':' ),
localBaseScript = mw.util.wikiScript() + '?title=' + mw.util.wikiUrlencode( mw.config.get( 'wgFormattedNamespaces' )['6'] + ':' ),
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 );
}
});
});
}