How to embed YouTube videos in Laravel: The easy way
source link: https://sampo.co.uk/blog/how-to-embed-youtube-videos-in-laravel-the-easy-way
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to embed YouTube videos in Laravel: The easy way
Monday, 21 Sep 2020
I released a package recently which makes embedding YouTube videos incredibly simple: laravel-embed.
Once it's installed, you simply make use of the included x-embed
blade component passing the URL of the video in the url
attribute:
<x-embed url="https://www.youtube.com/watch?v=oHg5SJYRHA0" />
This will render the video in an iFrame. It's responsive out of the box and isn't just limited to YouTube - it also supports Vimeo and a selection of other services.
That's it. Dead simple.
laravel-embed has a bunch of other features too, such as validation rules and being able to set the aspect ratio. See the project docs
Share this article
Did you like this article? Share it on Facebook and Twitter. Don't forget to subscribe too.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK