Skip to content

Commit

Permalink
Use class to set the width.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Jun 8, 2022
1 parent 93a922d commit 43f3c1f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions srs-player/public/class-srs-player-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,20 @@ public function embed_handler($atts = [], $content = null, $tag = '') {
$muted = " muted=${vMuted}";
if ($q['muted'] != 'true' && $q['muted'] != 'muted') $muted = '';

$vWidth = $q['width'];
$width = " width=\"${vWidth}\"";
$width = $q['width'];
if (empty($q['width'])) $width = '';
if (!strpos($width, '%') && !strpos($width, 'px')) $width = "${width}px";

// We must use style to setup the width, or some theme like 2020 will set height to 0.
$style = '';
if (!empty($width)) $style = "<style>#${id} { width: {$width}; } </style>";

$o = <<<EOT
<div class="srs-player-wrapper">
<video id="${id}" ${controls}${autoplay}${muted}${width}></video>
<video id="${id}" ${controls}${autoplay}${muted}></video>
<script>(function($) { new SrsPlayer("#${id}", "${url}").play(); })(jQuery);</script>
</div>
$style
EOT;
return $o;
}
Expand Down

0 comments on commit 43f3c1f

Please sign in to comment.