raff
raff

Reputation: 433

how to upload and show an embedded youtube video in Laravel

I want to upload an embedded youtube video in my laravel website.

For that I have uploaded an embedded youtube video link (provides from youtube embed option) in my admin panel and saved to database. Then I retrieved the video links from database and try to show it in blade template. But frontend only shows the video link as it saved in the database not the video.

<iframe width="300" height="220" src="https://www.youtube.com/embed/6T8stXj7Dzg?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

But if I manually used the links in the html then the video successfully shown.Like below code

<div id="panel-9-11-0-0" class="so-panel widget widget_sow-editor panel-first-child" data-index="27" >              
    <iframe width="300" height="220" src="https://www.youtube.com/embed/E7SCzULQYUQ?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
    <h3>title</h3>
</div>

How can I solve it ?

Upvotes: 2

Views: 6638

Answers (1)

raff
raff

Reputation: 433

Follow the link to setup laravel project for uploading an embedded video in laravel

https://packagist.org/packages/cohensive/embed

blade part

@foreach($video as $data)
    <div class="media">
        <h4>{{ $data->title }}</h4>
        <div class="media-body">
            {!! Embed::make($data->links)->parseUrl()->getIframe() !!}
        </div>
    </div>
@endforeach

Upvotes: 3

Related Questions