diff --git a/public/js/pimcore/object/tags/video.js b/public/js/pimcore/object/tags/video.js index dcd242250..89192f588 100644 --- a/public/js/pimcore/object/tags/video.js +++ b/public/js/pimcore/object/tags/video.js @@ -301,10 +301,13 @@ pimcore.object.tags.video = Class.create(pimcore.object.tags.abstract, { var match, regExp; if (values["type"] == "youtube") { - regExp = /^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/; - match = values["data"].match(regExp); - if (match && match[2].length == 11) { - values["data"] = match[2]; + // https://gist.github.com/afeld/1254889 + const ytRegex = /^(?:https?:\/\/|\/\/)?(?:www\.|m\.|.+\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|shorts\/|feeds\/api\/videos\/|watch\?v=|watch\?.+&v=))(?[\w-]{11})(?![\w-])/g; + match = values["data"].matchAll(ytRegex); + let matches = [...match] + let videoIds = Array.from(matches, m => m[1]); + if (videoIds && (videoIds[0] ?? null)) { + values["data"] = videoIds[0]; } } else if (values["type"] == "vimeo") { regExp = /vimeo.com\/(\d+)($|\/)/;