From 74cf2caca5dd182662428908212ee1b054c4ebc2 Mon Sep 17 00:00:00 2001 From: Michael Aschauer Date: Wed, 22 Oct 2025 13:10:47 +0200 Subject: [PATCH 1/4] add aspect-ratio --- syntax/video.php | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/syntax/video.php b/syntax/video.php index b54094e..5c77347 100644 --- a/syntax/video.php +++ b/syntax/video.php @@ -85,6 +85,7 @@ public function handle($match, $state, $pos, Doku_Handler $handler) [$vid, $pstr] = sexplode('?', $vid, 2, ''); parse_str($pstr, $userparams); [$width, $height] = $this->parseSize($userparams); + [$aspect_w, $aspect_h] = $this->parseAspect($userparams); // get URL $url = $this->insertPlaceholders($this->sites[$site]['url'], $vid, $width, $height); @@ -103,7 +104,9 @@ public function handle($match, $state, $pos, Doku_Handler $handler) 'align' => $this->alignments[$align], 'width' => $width, 'height' => $height, - 'title' => $title + 'title' => $title, + 'aspect_w' => $aspect_w, + 'aspect_h' => $aspect_h ]; } @@ -133,7 +136,7 @@ public function iframe($data, $element = 'iframe') 'src' => $data['url'], 'width' => $data['width'], 'height' => $data['height'], - 'style' => $this->sizeToStyle($data['width'], $data['height']), + 'style' => $this->sizeToStyle($data['width'], $data['height']) . $this->aspectToStyle($data['aspect_w'], $data['aspect_h']), 'class' => 'vshare vshare__' . $data['align'], 'allowfullscreen' => '', 'frameborder' => 0, @@ -174,6 +177,24 @@ public function sizeToStyle($width, $height) return $style; } + /** + * Create a style attribute for the given size + * + * @param int|string $width + * @param int|string $height + * @return string + */ + public function aspectToStyle($w, $h) + { + $style = ''; + if ($w > 0 && $h > 0) { + $style .= 'aspect-ratio:' . $w . '/' . $h . '; height: unset'; + } + return $style; + } + + + /** * Prepare the HTML for output in PDF exports * @@ -246,6 +267,27 @@ public function parseSize(&$params) return $this->sizes['medium']; } + /** + * Extract the wanted aspect from the parameter list + * + * @param array $params + * @return int[] + */ + public function parseAspect(&$params) + { + foreach (array_keys($params) as $key) { + if (preg_match("/^((\d+):(\d+))\$/i", $key, $m)) { + unset($params[$key]); + if (isset($m[2]) && isset($m[3])) { + return [$m[2], $m[3]]; + } else { + return []; + } + } + } + return []; + } + /** * Get additional attributes to set on the iframe to harden * From 69b1c71edc5305647150359df990464a0eafc4c1 Mon Sep 17 00:00:00 2001 From: Michael Aschauer Date: Wed, 22 Oct 2025 13:11:28 +0200 Subject: [PATCH 2/4] coerce back to string --- syntax/video.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/video.php b/syntax/video.php index 5c77347..89bec18 100644 --- a/syntax/video.php +++ b/syntax/video.php @@ -163,11 +163,11 @@ public function iframe($data, $element = 'iframe') public function sizeToStyle($width, $height) { // no unit? use px - if ($width && $width == (int)$width) { + if ($width && $width == (int)$width . '') { $width .= 'px'; } // no unit? use px - if ($height && $height == (int)$height) { + if ($height && $height == (int)$height . '') { $height .= 'px'; } From 5232e3ed3e14b35b0fe071118d8f25d3e0384c36 Mon Sep 17 00:00:00 2001 From: Michael Aschauer Date: Thu, 23 Oct 2025 15:59:18 +0200 Subject: [PATCH 3/4] stwst site ini --- sites.ini | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sites.ini b/sites.ini index 03413d2..bdd2c8b 100644 --- a/sites.ini +++ b/sites.ini @@ -6,6 +6,20 @@ ; rex = a regular expression that can extract the vid from the web or emb url ; nfo = a hint on how to find the right URL to paste +[stwst] +url = //video.stwst.at/videos/embed/@VIDEO@ +vid = n4CcD7kUDcZgjsSbn465 +web = https://video.stwst.at/w/n4CcD7kUDcZgjsSbn465Sk +rex = video.stwst.at/w/([a-z0-9_\-]+) + +[video] +url = //video.stwst.at/videos/embed/@VIDEO@ +vid = n4CcD7kUDcZgjsSbn465 +web = https://video.stwst.at/w/n4CcD7kUDcZgjsSbn465Sk +rex = video.stwst.at/w/([a-z0-9_\-]+) + + + [youtube] url = //www.youtube-nocookie.com/embed/@VIDEO@ vid = W86cTIoMv2U From efbfff9d8c8d082f916667ea69f3b39addc73473 Mon Sep 17 00:00:00 2001 From: Michael Aschauer Date: Fri, 24 Oct 2025 13:46:00 +0200 Subject: [PATCH 4/4] Revert "stwst site ini" This reverts commit 5232e3ed3e14b35b0fe071118d8f25d3e0384c36. --- sites.ini | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/sites.ini b/sites.ini index bdd2c8b..03413d2 100644 --- a/sites.ini +++ b/sites.ini @@ -6,20 +6,6 @@ ; rex = a regular expression that can extract the vid from the web or emb url ; nfo = a hint on how to find the right URL to paste -[stwst] -url = //video.stwst.at/videos/embed/@VIDEO@ -vid = n4CcD7kUDcZgjsSbn465 -web = https://video.stwst.at/w/n4CcD7kUDcZgjsSbn465Sk -rex = video.stwst.at/w/([a-z0-9_\-]+) - -[video] -url = //video.stwst.at/videos/embed/@VIDEO@ -vid = n4CcD7kUDcZgjsSbn465 -web = https://video.stwst.at/w/n4CcD7kUDcZgjsSbn465Sk -rex = video.stwst.at/w/([a-z0-9_\-]+) - - - [youtube] url = //www.youtube-nocookie.com/embed/@VIDEO@ vid = W86cTIoMv2U