From 4cc32f979a5f0f9addfd312fe78489267703062e Mon Sep 17 00:00:00 2001 From: Derk-Jan Hartman Date: Sun, 31 Oct 2010 21:49:25 +0000 Subject: [PATCH] Add a new isVectorized() to files and media handlers. Only SVG returns true. Related to Bug 19633. --- includes/filerepo/File.php | 13 +++++++++++++ includes/media/Generic.php | 4 ++++ includes/media/SVG.php | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/includes/filerepo/File.php b/includes/filerepo/File.php index 77b1b16bdf..063fb169da 100644 --- a/includes/filerepo/File.php +++ b/includes/filerepo/File.php @@ -266,6 +266,19 @@ abstract class File { } } + /** + * Get the duration of a media file in seconds + */ + public function isVectorized() { + $handler = $this->getHandler(); + if ( $handler ) { + return $handler->isVectorized( $this ); + } else { + return false; + } + } + + /** * Get handler-specific metadata * Overridden by LocalFile, UnregisteredLocalFile diff --git a/includes/media/Generic.php b/includes/media/Generic.php index db3f4ce38b..92f03045c3 100644 --- a/includes/media/Generic.php +++ b/includes/media/Generic.php @@ -161,6 +161,10 @@ abstract class MediaHandler { * Page count for a multi-page document, false if unsupported or unknown */ function pageCount( $file ) { return false; } + /** + * The material is vectorized and thus scaling is lossless + */ + function isVectorized( $file ) { return false; } /** * False if the handler is disabled for all files */ diff --git a/includes/media/SVG.php b/includes/media/SVG.php index 242b2645b7..c2541659fb 100644 --- a/includes/media/SVG.php +++ b/includes/media/SVG.php @@ -26,6 +26,10 @@ class SvgHandler extends ImageHandler { return true; } + function isVectorized( $file ) { + return true; + } + function normaliseParams( $image, &$params ) { global $wgSVGMaxSize; if ( !parent::normaliseParams( $image, $params ) ) { -- 2.20.1