return false;
}
+ /**
+ * We do not support making animated svg thumbnails
+ */
+ function canAnimateThumb( $file ) {
+ return false;
+ }
+
/**
* @param $image File
* @param $params
$clientHeight = $params['height'];
$physicalWidth = $params['physicalWidth'];
$physicalHeight = $params['physicalHeight'];
- $srcPath = $image->getLocalRefPath();
if ( $flags & self::TRANSFORM_LATER ) {
return new ThumbnailImage( $image, $dstUrl, $clientWidth, $clientHeight, $dstPath );
if ( !wfMkdirParents( dirname( $dstPath ), null, __METHOD__ ) ) {
return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight,
- wfMsg( 'thumbnail_dest_directory' ) );
+ wfMessage( 'thumbnail_dest_directory' )->text() );
}
+ $srcPath = $image->getLocalRefPath();
$status = $this->rasterize( $srcPath, $dstPath, $physicalWidth, $physicalHeight );
if( $status === true ) {
return new ThumbnailImage( $image, $dstUrl, $clientWidth, $clientHeight, $dstPath );
}
/**
+ * Subtitle for the image. Different from the base
+ * class so it can be denoted that SVG's have
+ * a "nominal" resolution, and not a fixed one,
+ * as well as so animation can be denoted.
+ *
* @param $file File
* @return string
*/
function getLongDesc( $file ) {
global $wgLang;
- return wfMsgExt( 'svg-long-desc', 'parseinline',
- $wgLang->formatNum( $file->getWidth() ),
- $wgLang->formatNum( $file->getHeight() ),
- $wgLang->formatSize( $file->getSize() ) );
+ $size = $wgLang->formatSize( $file->getSize() );
+
+ if ( $this->isAnimatedImage( $file ) ) {
+ $msg = wfMessage( 'svg-long-desc-animated' );
+ } else {
+ $msg = wfMessage( 'svg-long-desc' );
+ }
+
+ $msg->numParams(
+ $file->getWidth(),
+ $file->getHeight()
+ );
+ $msg->Params( $size );
+ return $msg->parse();
}
function getMetadata( $file, $filename ) {
}
function isMetadataValid( $image, $metadata ) {
- return $this->unpackMetadata( $metadata ) !== false;
+ $meta = $this->unpackMetadata( $metadata );
+ if ( $meta === false ) {
+ return self::METADATA_BAD;
+ }
+ if ( !isset( $meta['originalWidth'] ) ) {
+ // Old but compatible
+ return self::METADATA_COMPATIBLE;
+ }
+ return self::METADATA_GOOD;
}
function visibleMetadataFields() {
- $fields = array( 'title', 'description', 'animated' );
+ $fields = array( 'objectname', 'imagedescription' );
return $fields;
}
if ( !$metadata ) {
return false;
}
- unset( $metadata['version'] );
- unset( $metadata['metadata'] ); /* non-formatted XML */
/* TODO: add a formatter
$format = new FormatSVG( $metadata );
$visibleFields = $this->visibleMetadataFields();
// Rename fields to be compatible with exif, so that
- // the labels for these fields work.
- $conversion = array( 'width' => 'imagewidth',
- 'height' => 'imagelength',
+ // the labels for these fields work and reuse existing messages.
+ $conversion = array(
+ 'originalwidth' => 'imagewidth',
+ 'originalheight' => 'imagelength',
'description' => 'imagedescription',
'title' => 'objectname',
);
$tag = strtolower( $name );
if ( isset( $conversion[$tag] ) ) {
$tag = $conversion[$tag];
+ } else {
+ // Do not output other metadata not in list
+ continue;
}
self::addMeta( $result,
in_array( $tag, $visibleFields ) ? 'visible' : 'collapsed',