Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

greder's avatar

embed youtube not working /dropping error

What is not working correctly in this embed youtube code below? Idea is that link for a youtube video is inserted from admin panel and then it should be displayed on main page. But it is showing error, the code is:

public function getDescription()
    {
        $description = $this->{'description_' . app()->getLocale()};
        $description = preg_replace('/<figure class="media"><oembed url="https:\/\/youtu.be\/(.*?)"><\/oembed><\/figure>/', '<iframe width="560" height="315" src="https://www.youtube.com/embed/" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>', $description);

        return $description;
0 likes
5 replies
Snapey's avatar

what error?

You have not formatted the code in the question correctly, but it looks like invalid php to me

greder's avatar

@Snapey It is showing youtube error saying " Firefox Can’t Open This Page

To protect your security, www.youtube.com will not allow Firefox to display the page if another site has embedded it. To see this page, you need to open it in a new window.

Please or to participate in this conversation.