loburets
7/26/2017 - 1:01 PM

Embed video from youtube via link parsing

Embed video from youtube via link parsing

@if(preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $link, $match))
    <iframe type="text/html"
            src="https://www.youtube.com/embed/{!! $match[1] !!}?rel=0&showinfo=0&color=white&iv_load_policy=3"
            frameborder="0" allowfullscreen></iframe>
@elseif (!empty($link))
    <a href="{!! $link !!}">Video</a>
@endif