Brion VIBBER has uploaded a new change for review.
https://gerrit.wikimedia.org/r/287074
Change subject: [WIP] Experimental $wgSVGClientSideRendering option
......................................................................
[WIP] Experimental $wgSVGClientSideRendering option
Implemented via srcset.
Todo:
* fix jquery.hidpi polyfill to test for SVG support
* add release notes & docs
Beware that this will probably not render correctly sometimes.
In particular, localized SVGs will not work as expected, and
server-side fonts do not get used.
There is no checking for massively oversized SVGs etc, so
performance may actually suffer. Very experimental. :)
Bug: T134455
Change-Id: I2f655ed162f98f01f17a9aad24ab9d1d518615fc
---
M includes/DefaultSettings.php
M includes/Linker.php
M includes/media/SVG.php
3 files changed, 28 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/74/287074/1
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index d65e0ad..5b948d3 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -1057,6 +1057,17 @@
$wgSVGMetadataCutoff = 262144;
/**
+ * Experimental option to serve SVGs directly to browsers supporting it.
+ * A rasterized PNG is still produced and served as a backup.
+ *
+ * Warning: this does not yet correctly handle localized text, and may
+ * have other problems.
+ *
+ * @since 1.28
+ */
+$wgSVGClientSideRendering = false;
+
+/**
* Disallow <title> element in SVG files.
*
* MediaWiki will reject HTMLesque tags in uploaded files due to idiotic
diff --git a/includes/Linker.php b/includes/Linker.php
index 6a869dd..28b9c7b 100644
--- a/includes/Linker.php
+++ b/includes/Linker.php
@@ -886,7 +886,7 @@
*/
public static function processResponsiveImages( $file, $thumb, $hp ) {
global $wgResponsiveImages;
- if ( $wgResponsiveImages && $thumb && !$thumb->isError() ) {
+ if ( $wgResponsiveImages && $thumb && !$thumb->isError() &&
count( $thumb->responsiveUrls ) == 0 ) {
$hp15 = $hp;
$hp15['width'] = round( $hp['width'] * 1.5 );
$hp20 = $hp;
diff --git a/includes/media/SVG.php b/includes/media/SVG.php
index 2bb6d13..9b29dad 100644
--- a/includes/media/SVG.php
+++ b/includes/media/SVG.php
@@ -172,7 +172,7 @@
$lang = isset( $params['lang'] ) ? $params['lang'] :
$this->getDefaultRenderLanguage( $image );
if ( $flags & self::TRANSFORM_LATER ) {
- return new ThumbnailImage( $image, $dstUrl, $dstPath,
$params );
+ return $this->vectorizeThumbnail( $image, new
ThumbnailImage( $image, $dstUrl, $dstPath, $params ) );
}
$metadata = $this->unpackMetadata( $image->getMetadata() );
@@ -224,13 +224,27 @@
$status = $this->rasterize( $lnPath, $dstPath, $physicalWidth,
$physicalHeight, $lang );
if ( $status === true ) {
- return new ThumbnailImage( $image, $dstUrl, $dstPath,
$params );
+ return $this->vectorizeThumbnail( $image, new
ThumbnailImage( $image, $dstUrl, $dstPath, $params ) );
} else {
return $status; // MediaTransformError
}
}
/**
+ * If enabled, add a direct SVG in addition to the rasterization to
thumb.
+ * @param File $image
+ * @param ThumbnailImage $thumb
+ * @return ThumbnailImage
+ */
+ protected function vectorizeThumbnail( $image, $thumb ) {
+ global $wgSVGClientSideRendering;
+ if ( $wgSVGClientSideRendering ) {
+ $thumb->responsiveUrls['1'] = $image->getUrl();
+ }
+ return $thumb;
+ }
+
+ /**
* Transform an SVG file to PNG
* This function can be called outside of thumbnail contexts
* @param string $srcPath
--
To view, visit https://gerrit.wikimedia.org/r/287074
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2f655ed162f98f01f17a9aad24ab9d1d518615fc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Brion VIBBER <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits