2 * Add magnify links to thumbs and resize broken media spans, where needed
5 mw.hook( 'wikipage.content' ).add( ( $content ) => {
7 'figure[typeof~="mw:File/Thumb"] > :not(figcaption) .mw-file-element'
9 const inner = this.parentNode;
10 const wrapper = inner.parentNode;
12 if ( this.classList.contains( 'mw-broken-media' ) ) {
13 // Resize broken media spans, where needed
14 const isDefault = wrapper.classList.contains( 'mw-default-size' );
18 if ( this.hasAttribute( 'data-width' ) ) {
19 this.style.width = this.getAttribute( 'data-width' ) + 'px';
21 if ( this.hasAttribute( 'data-height' ) ) {
22 this.style.height = this.getAttribute( 'data-height' ) + 'px';
25 // Add magnify links to thumbs, where needed
26 const resource = this.getAttribute( 'resource' );
30 if ( inner.classList.contains( 'mw-file-description' ) ) {
33 const desc = this.ownerDocument.createElement( 'a' );
34 desc.setAttribute( 'href', resource );
35 // Using a different class than mw-file-description to avoid the
36 // expectation that the media will be found inside it
37 desc.classList.add( 'mw-file-magnify' );
38 wrapper.insertBefore( desc, inner.nextSibling );