Loading CHANGELOG.txt +2 −0 Changes for CHANGELOG.txt: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Video_Filter 8.x-1.x-dev, xxxx-xx-xx ------------------------------------ #3317830 by DamienMcKenna, malcomio: "Unsupported operand type" error on Youtube video. Video_Filter 8.x-1.1, 2022-09-02 Loading src/Plugin/VideoFilter/Youtube.php +36 −7 Changes for src/Plugin/VideoFilter/Youtube.php: 36 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -47,14 +47,13 @@ class Youtube extends VideoFilterBase { $attributes['list'] = 'list=' . $matches[2][0]; } } if (preg_match('/[\?|&]t=((?<minutes>\d+m)?(?<seconds>\d+s?)?)/', $video['source'], $matches)) { $attributes['start'] = 'start=' . (preg_replace("/[^0-9]/", "", $matches['minutes']) * 60 + (preg_replace("/[^0-9]/", "", $matches['seconds']))); } if (!empty($video['start'])) { if (preg_match('/((?<minutes>\d+m)?(?<seconds>\d+s?)?)/', $video['start'], $matches)) { $attributes['start'] = 'start=' . (preg_replace("/[^0-9]/", "", $matches['minutes']) * 60 + (preg_replace("/[^0-9]/", "", $matches['seconds']))); } // Look for a start time attribute. $start = $this->convertStartTime($video); if (!empty($start)) { $attributes['start'] = $start; } return $attributes; } Loading Loading @@ -146,4 +145,34 @@ class Youtube extends VideoFilterBase { return $form; } /** * Extract a start time from a YouTube video URL. * * @param array $video * The video array. * * @return string|null * The start time ready to add as an attribute. */ function convertStartTime(array $video) { $start = NULL; $fields_to_search = [ 'source', 'start', ]; foreach ($fields_to_search as $field) { if (!empty($video[$field]) && preg_match('/[\?|&]t=((?<minutes>\d+m)?(?<seconds>\d+s?)?)/', $video[$field], $matches)) { $minutes = intval($matches['minutes']); $seconds = intval($matches['seconds']); // Total up the number of minutes and seconds. $start = 'start=' . (preg_replace("/[^0-9]/", "", $minutes) * 60 + (preg_replace("/[^0-9]/", "", $seconds))); } } return $start; } } Loading
CHANGELOG.txt +2 −0 Changes for CHANGELOG.txt: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Video_Filter 8.x-1.x-dev, xxxx-xx-xx ------------------------------------ #3317830 by DamienMcKenna, malcomio: "Unsupported operand type" error on Youtube video. Video_Filter 8.x-1.1, 2022-09-02 Loading
src/Plugin/VideoFilter/Youtube.php +36 −7 Changes for src/Plugin/VideoFilter/Youtube.php: 36 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -47,14 +47,13 @@ class Youtube extends VideoFilterBase { $attributes['list'] = 'list=' . $matches[2][0]; } } if (preg_match('/[\?|&]t=((?<minutes>\d+m)?(?<seconds>\d+s?)?)/', $video['source'], $matches)) { $attributes['start'] = 'start=' . (preg_replace("/[^0-9]/", "", $matches['minutes']) * 60 + (preg_replace("/[^0-9]/", "", $matches['seconds']))); } if (!empty($video['start'])) { if (preg_match('/((?<minutes>\d+m)?(?<seconds>\d+s?)?)/', $video['start'], $matches)) { $attributes['start'] = 'start=' . (preg_replace("/[^0-9]/", "", $matches['minutes']) * 60 + (preg_replace("/[^0-9]/", "", $matches['seconds']))); } // Look for a start time attribute. $start = $this->convertStartTime($video); if (!empty($start)) { $attributes['start'] = $start; } return $attributes; } Loading Loading @@ -146,4 +145,34 @@ class Youtube extends VideoFilterBase { return $form; } /** * Extract a start time from a YouTube video URL. * * @param array $video * The video array. * * @return string|null * The start time ready to add as an attribute. */ function convertStartTime(array $video) { $start = NULL; $fields_to_search = [ 'source', 'start', ]; foreach ($fields_to_search as $field) { if (!empty($video[$field]) && preg_match('/[\?|&]t=((?<minutes>\d+m)?(?<seconds>\d+s?)?)/', $video[$field], $matches)) { $minutes = intval($matches['minutes']); $seconds = intval($matches['seconds']); // Total up the number of minutes and seconds. $start = 'start=' . (preg_replace("/[^0-9]/", "", $minutes) * 60 + (preg_replace("/[^0-9]/", "", $seconds))); } } return $start; } }