TheDJ has uploaded a new change for review. https://gerrit.wikimedia.org/r/298872
Change subject: Revert "TimedMediaHandler: Don't try to calculate width and height for audio files" ...................................................................... Revert "TimedMediaHandler: Don't try to calculate width and height for audio files" This reverts commit 1c9d3e1adbfbfcbeec3a0c9b80a17d922a5ee2fc. Change-Id: I91c5fa8ca5586be7fa03b61efbc56ee61e02d79e --- M TimedMediaHandler_body.php 1 file changed, 14 insertions(+), 21 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler refs/changes/72/298872/1 diff --git a/TimedMediaHandler_body.php b/TimedMediaHandler_body.php index d766449..b3419f8 100644 --- a/TimedMediaHandler_body.php +++ b/TimedMediaHandler_body.php @@ -364,14 +364,24 @@ return new TransformParameterError( $params ); } + $srcWidth = $file->getWidth(); + $srcHeight = $file->getHeight(); + + $params['width'] = isset( $params['width'] ) ? $params['width'] : $srcWidth; + + // if height overtakes width use height as max: + $targetWidth = $params['width']; + $targetHeight = $srcWidth == 0 ? $srcHeight : round( $params['width'] * $srcHeight / $srcWidth ); + if ( isset( $params['height'] ) && $targetHeight > $params['height'] ) { + $targetHeight = $params['height']; + $targetWidth = round( $params['height'] * $srcWidth / $srcHeight ); + } $options = [ 'file' => $file, 'length' => $this->getLength( $file ), 'offset' => $this->getOffset( $file ), - // Thumbnail width and height for audio files is hardcoded to match the dimensions of the - // filetype icon, see TimedMediaTransformOutput::getUrl(). Overridden for video below. - 'width' => 120, - 'height' => 120, + 'width' => $targetWidth, + 'height' => $targetHeight, 'isVideo' => !$this->isAudio( $file ), 'thumbtime' => isset( $params['thumbtime'] @@ -386,23 +396,6 @@ if ( !$options['isVideo'] ) { return new TimedMediaTransformOutput( $options ); } - - // We're dealing with a video file now, set width and height - $srcWidth = $file->getWidth(); - $srcHeight = $file->getHeight(); - - $params['width'] = isset( $params['width'] ) ? $params['width'] : $srcWidth; - - // if height overtakes width use height as max: - $targetWidth = $params['width']; - $targetHeight = $srcWidth == 0 ? $srcHeight : round( $params['width'] * $srcHeight / $srcWidth ); - if ( isset( $params['height'] ) && $targetHeight > $params['height'] ) { - $targetHeight = $params['height']; - $targetWidth = round( $params['height'] * $srcWidth / $srcHeight ); - } - - $options[ 'width' ] = $targetWidth; - $options[ 'height' ] = $targetHeight; // Setup pointer to thumb arguments $options[ 'thumbUrl' ] = $dstUrl; -- To view, visit https://gerrit.wikimedia.org/r/298872 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I91c5fa8ca5586be7fa03b61efbc56ee61e02d79e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TimedMediaHandler Gerrit-Branch: master Gerrit-Owner: TheDJ <hartman.w...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits