Page MenuHomeWickedGov Phorge

mediawiki.page.media.js
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

mediawiki.page.media.js

/*!
* Add magnify links to thumbs and resize broken media spans, where needed
*/
( function () {
mw.hook( 'wikipage.content' ).add( ( $content ) => {
$content.find(
'figure[typeof~="mw:File/Thumb"] > :not(figcaption) .mw-file-element'
).each( function () {
const inner = this.parentNode;
const wrapper = inner.parentNode;
if ( this.classList.contains( 'mw-broken-media' ) ) {
// Resize broken media spans, where needed
const isDefault = wrapper.classList.contains( 'mw-default-size' );
if ( isDefault ) {
return;
}
if ( this.hasAttribute( 'data-width' ) ) {
this.style.width = this.getAttribute( 'data-width' ) + 'px';
}
if ( this.hasAttribute( 'data-height' ) ) {
this.style.height = this.getAttribute( 'data-height' ) + 'px';
}
} else {
// Add magnify links to thumbs, where needed
const resource = this.getAttribute( 'resource' );
if ( !resource ) {
return;
}
if ( inner.classList.contains( 'mw-file-description' ) ) {
return;
}
const desc = this.ownerDocument.createElement( 'a' );
desc.setAttribute( 'href', resource );
// Using a different class than mw-file-description to avoid the
// expectation that the media will be found inside it
desc.classList.add( 'mw-file-magnify' );
wrapper.insertBefore( desc, inner.nextSibling );
}
} );
} );
}() );

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 8, 01:49 (1 d, 6 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f5/77/2e459576cd7da72bead58057c5e4
Default Alt Text
mediawiki.page.media.js (1 KB)

Event Timeline