From bfdfadbb2c451e89e5c3fa7286479af4089b53e1 Mon Sep 17 00:00:00 2001
From: Kevin Paxman <kpaxman@uwaterloo.ca>
Date: Mon, 3 Feb 2025 11:14:42 -0500
Subject: [PATCH] ISTWCMS-7251: add support for YouTube shorts

---
 src/EventSubscriber/UwCblRemoteVideoEventSubscriber.php | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/EventSubscriber/UwCblRemoteVideoEventSubscriber.php b/src/EventSubscriber/UwCblRemoteVideoEventSubscriber.php
index c535df19..96132369 100644
--- a/src/EventSubscriber/UwCblRemoteVideoEventSubscriber.php
+++ b/src/EventSubscriber/UwCblRemoteVideoEventSubscriber.php
@@ -73,11 +73,17 @@ class UwCblRemoteVideoEventSubscriber extends UwCblBase implements EventSubscrib
         $remote_video['view']['type'] = 'YouTube';
       }
       // Check for YouTube playlist.
-      elseif (preg_match($pattern = '/^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/(playlist\?list=)([a-zA-Z0-9_-]+)$/', $remote_video['view']['url'])) {
+      elseif (preg_match('/^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/(playlist\?list=)([a-zA-Z0-9_-]+)$/', $remote_video['view']['url'])) {
 
         // Set the type of video to YouTube playlist.
         $remote_video['view']['type'] = 'YouTube playlist';
       }
+      // Check for YouTube short.
+      elseif (preg_match('/https?:\/\/(www\.)?youtube\.com\/shorts\/[a-zA-Z0-9_-]+/', $remote_video['view']['url'])) {
+
+        // Set the type of video to YouTube short.
+        $remote_video['view']['type'] = 'YouTube short';
+      }
       // Check for Vimeo.
       elseif (strrpos($remote_video['view']['url'], 'vimeo')) {
 
-- 
GitLab