@biell Thanks for chipping in :)
I'm thinking it might be easier to setup the regex to fail if the link has anything after the ID so that it will just show as a link and not replace with the embed. At least that way the site won't try to always generate an embed and mess up anything else intended in the URL like a playlist.
.
The plugin seems pretty simple, it looks like it just allows you to have a template for an output then uses regex to filter out and feed certain parts.
The default regex given is:
(?:<a.*?)?(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?!user|channel)\S*(?:(?:\/e(?:mbed))?\/|watch\?(?:\S*?&?v\=))|youtu\.be\/)([a-zA-Z0-9_-]{6,11})(?:.*?\/a>)?
By default it just looks for a youtube link and then takes the ID at the end like below.
https://www.youtube.com/watch?v= f0i-KnPu4Rw
That then feeds into the template given below. $1 will be whatever was captured by ([a-zA-Z0-9_-]{6,11})
<div class='embed-wrapper'>
<div class='embed-container'>
<iframe src='https://www.youtube.com/embed/$1' frameborder='0' allowfullscreen>
</iframe>
</div>
</div>
Youtube timestamps work by adding ?t= followed by the seconds from start however in embeds for some reason they use ?start=. So the regex would need to look for ?t= and generate a second capture for whatever comes after (numeric only). Link example below.
https://youtu.be/ f0i-KnPu4Rw ?t= 12
Played around in https://regex101.com/ as recommended by @NotSure using the substitution function to feed the info into the embed template. So far I can capture the data fine but none of my attempts generate a valid output under both scenarios (ID only or ID and timestamp).
This change to the template works but I can't manipulate the regex to pass data in both scenarios without 1 of the scenarios failing :(
https://www.youtube.com/embed/$1?start=0$2
Brings me back to my initial thought of having regex consider a link invalid if it has anything following the video ID.