diff options
author | Arlo Breault <abreault@wikimedia.org> | 2023-05-11 22:16:25 -0400 |
---|---|---|
committer | Arlo Breault <abreault@wikimedia.org> | 2023-05-24 20:08:55 -0400 |
commit | 5265579c0f9a11254811b50b3e72cbd8fbd83ede (patch) | |
tree | 2aef8f05c676c5f3f2a54d6c1e5d7dafa1702dd1 /includes/media/ThumbnailImage.php | |
parent | f6dc03a0757eef2f4a6e1b30a2155c57c4011706 (diff) | |
download | mediawikicore-5265579c0f9a11254811b50b3e72cbd8fbd83ede.tar.gz mediawikicore-5265579c0f9a11254811b50b3e72cbd8fbd83ede.zip |
Add magnify links on thumbs when not linking to file desc page
This is all in the context of !$enableLegacyMediaDOM where explicit
magnify links aren't added to the html.
If we're linking to the file description page, magnify links are already
added via css. However, if we're not, we're missing both the url for
the media and something to click on, which can't be added with css.
Here we add the necessary url as a resource attribute on the
mw-file-element. Parsoid already does this unconditionally so there's
precedent for it. And, in the common case, there isn't any redundancy
since it will be omitted where mw-file-description links are present.
A script is provided to add the magnify links where needed. These
aren't added directly to the html since they are considered purely
presentational. Though they're styled the same as mw-file-description
links, they are given a different class, mw-file-magnify, to avoid any
confusion about their purpose and the expectation that the media element
would be found inside them.
As above, since the legacy output always includes the magnify links in
the html, it's a significant reduction in size to only be including the
resource attribute where necessary and adding the links via css.
Bug: T329413
Depends-On: Ia22eeef770980fd555fdeb83049fc0ff700be884
Change-Id: Id46d1b2ab1af3baebff13e10f1485f3cfd9a4b37
Diffstat (limited to 'includes/media/ThumbnailImage.php')
-rw-r--r-- | includes/media/ThumbnailImage.php | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/includes/media/ThumbnailImage.php b/includes/media/ThumbnailImage.php index ba4838a16d97..99011f9a1a03 100644 --- a/includes/media/ThumbnailImage.php +++ b/includes/media/ThumbnailImage.php @@ -110,6 +110,7 @@ class ThumbnailImage extends MediaTransformOutput { * parser-extlink-* Attributes added by parser for external links: * parser-extlink-rel: add rel="nofollow" * parser-extlink-target: link target, but overridden by custom-target-link + * magnify-resource To set the HTML resource attribute, when necessary * * For images, desc-link and file-link are implemented as a click-through. For * sounds and videos, they may be displayed in other ways. @@ -138,6 +139,16 @@ class ThumbnailImage extends MediaTransformOutput { $attribs['alt'] = $options['alt']; } + // Description links get the mw-file-description class and link + // to the file description page, making the resource redundant + if ( + !$enableLegacyMediaDOM && + isset( $options['magnify-resource'] ) && + !( $options['desc-link'] ?? false ) + ) { + $attribs['resource'] = $options['magnify-resource']; + } + $attribs += [ 'src' => $this->url, 'decoding' => 'async', |