TheDJ has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/289551

Change subject: Remove poster attribute from <audio> elements
......................................................................

Remove poster attribute from <audio> elements

HTML5 <audio> elements do not have poster attributes. This wasn't
really used and was creating a hidden image. It now creates a hidden
1pixel fallback image for MwEmbed and properly omits the poster
completely for video.js

Bug: T135603
Change-Id: I30e29dcdff4a71fc7a30795117848536d7747429
---
M TimedMediaTransformOutput.php
M tests/parserTests.txt
2 files changed, 8 insertions(+), 7 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler 
refs/changes/51/289551/1

diff --git a/TimedMediaTransformOutput.php b/TimedMediaTransformOutput.php
index 31008e4..19758f3 100644
--- a/TimedMediaTransformOutput.php
+++ b/TimedMediaTransformOutput.php
@@ -406,9 +406,6 @@
                $width = $sizeOverride ? $sizeOverride[0] : 
$this->getPlayerWidth();
                $height = $sizeOverride ? $sizeOverride[1]: 
$this->getPlayerHeight();
 
-               // The poster url:
-               $posterUrl = $this->getUrl( $sizeOverride );
-
                if ( $this->fillwindow ) {
                        $width = '100%';
                        $height = '100%';
@@ -420,7 +417,7 @@
                $mediaAttr = [
                        'id' => self::PLAYER_ID_PREFIX . 
TimedMediaTransformOutput::$serial++,
                        // Get the correct size:
-                       'poster' => $posterUrl,
+                       'poster' => $this->getUrl( $sizeOverride ),
 
                        // Note we set controls to true ( for no-js players ) 
when mwEmbed rewrites the interface
                        // it updates the controls attribute of the embed video
@@ -434,6 +431,11 @@
                        $mediaAttr['autoplay'] = 'true';
                }
 
+               if ( !$this->isVideo ) {
+                       // audio element doesn't have poster attribute
+                       unset( $mediaAttr[ 'poster' ] );
+               }
+
                if ( $wgTmhWebPlayer === 'videojs' ) {
                        $mediaAttr['class'] = 'video-js ' . $wgVideoPlayerSkin;
                        $mediaAttr['width'] = intval( $width );
@@ -441,7 +443,6 @@
                                $mediaAttr['height'] = intval( $height );
                        } else {
                                unset( $mediaAttr['height'] );
-                               unset( $mediaAttr['poster'] );
                        }
 
                        if ( $this->disablecontrols ) {
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index c374316..a292c6d 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -102,9 +102,9 @@
 !! wikitext
 [[File:Audio.oga]]
 !! html
-<div class="mediaContainer" style="width:180px"><audio id="mwe_player_14" 
poster="/resources/assets/file-type-icons/fileicon-ogg.png" controls="" 
preload="none" style="width:180px" class="kskin" data-durationhint="0.99875" 
data-startoffset="0" data-mwtitle="Audio.oga" data-mwprovider="local"><source 
src="http://example.com/images/4/41/Audio.oga"; type="audio/ogg; 
codecs=&quot;vorbis&quot;" data-title="Original Ogg file (41 kbps)" 
data-shorttitle="Ogg source" data-width="0" data-height="0" 
data-bandwidth="41107"/></audio></div>
+<div class="mediaContainer" style="width:180px"><audio id="mwe_player_14" 
controls="" preload="none" style="width:180px" class="kskin" 
data-durationhint="0.99875" data-startoffset="0" data-mwtitle="Audio.oga" 
data-mwprovider="local"><source src="http://example.com/images/4/41/Audio.oga"; 
type="audio/ogg; codecs=&quot;vorbis&quot;" data-title="Original Ogg file (41 
kbps)" data-shorttitle="Ogg source" data-width="0" data-height="0" 
data-bandwidth="41107"/></audio></div>
 
 !! html+tidy
-<div class="mediaContainer" style="width:180px"><audio id="mwe_player_13" 
poster="/resources/assets/file-type-icons/fileicon-ogg.png" controls="" 
preload="none" style="width:180px" class="kskin" data-durationhint="0.99875" 
data-startoffset="0" data-mwtitle="Audio.oga" data-mwprovider="local">
+<div class="mediaContainer" style="width:180px"><audio id="mwe_player_13" 
controls="" preload="none" style="width:180px" class="kskin" 
data-durationhint="0.99875" data-startoffset="0" data-mwtitle="Audio.oga" 
data-mwprovider="local">
 <source src="http://example.com/images/4/41/Audio.oga"; type="audio/ogg; 
codecs=&quot;vorbis&quot;" data-title="Original Ogg file (41 kbps)" 
data-shorttitle="Ogg source" data-width="0" data-height="0" 
data-bandwidth="41107" /></audio></div>
 !!end

-- 
To view, visit https://gerrit.wikimedia.org/r/289551
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I30e29dcdff4a71fc7a30795117848536d7747429
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

Reply via email to