I have the following bbcode replacement for users to use when inserting a youtube video into a post:
HTML Code:
<iframe width="560" height="349" src="http://www.youtube.com/embed/{param}" frameborder="0" allowfullscreen></iframe>
This works great when the user uses the tag correctly and inserts only the video ID. However, if the user pastes in the entire URL, which they often do by mistake, it causes the entire thread to be redirected to youtube any time someone opens it.
Is there a way to handle the user putting in a full URL rather than just the video ID and fail gracefully?