I have this code and it works just fine.
if( strcasecmp( 'www.youtube.com/watch', $link[2] ) == 0 && $this->params( $params, $link[3], 'v' ) )
return '<iframe width="'.$width.'" height="'.$height.'" src="'.$link[1].'www.youtube.com/embed/'.$params['v'].'?rel=0&playsinline=1&controls=1&showinfo=0&modestbranding=0" frameborder="0" allowfullscreen></iframe>';
else if( preg_match( '/^(?:www\.)?youtu\.be\/([^\/]+)/i', $link[2], $matches ))
return '<iframe width="'.$width.'" height="'.$height.'" src="'.$link[1].'www.youtube.com/embed/'.$matches[1].'?rel=0&playsinline=1&controls=1&showinfo=0&modestbranding=0" frameborder="0" allowfullscreen></iframe>';
And it works just fine, with auto replace links with video. But now, youtube have this thing where short videos have a link with "Shorts"
Example: https://youtube.com/shorts/d1wXX9xO_2o?feature=share
That will not embed automatically. Any idea how to fix this?
I have tried:
else if( preg_match( '/^(?:www\.)?youtube\.com/shorts\/([^\/]+)/i', $link[2], $matches ))
return '<iframe width="'.$width.'" height="'.$height.'" src="'.$link[1].'www.youtube.com/embed/'.$matches[1].'?rel=0&playsinline=1&controls=1&showinfo=0&modestbranding=0" frameborder="0" allowfullscreen></iframe>';
But no luck.