laraveltwitter-bootstrapbootstrap-4facebook-iframe

Facebook page iFrame display problem in Boostrap Template while using Laravel as backend to send iframe code


I am using a bootstrap template. I want to display a Facebook page iFrame in sidebar. I am using following iFrame code which is generated by Facebook Page Plugin. Here is the code:

<iframe src="https://www.facebook.com/plugins/page.php?href=https%3A%2F%2Fwww.facebook.com%2Ffaporbazmedia%2F&tabs=timeline&width=270&height=540&small_header=false&adapt_container_width=false&hide_cover=false&show_facepile=false&appId" width="270" height="540" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true" allow="encrypted-media"></iframe>

It works fine and display Page iFrame if I directly put this code in the template. However, If I upload this code from backend and retrieve this code in the same place, it doesn't show the iFrame. It shows the raw code!

Here is the image. in the top, I have placed direct code and in the bottom I have retrieved code from MySQL database.

enter image description here

Here is the Laravel code by which I am trying to display the iFrame.

@if(isset($facebookpage))
    {{ $facebookpage->code }}
@endif

Solution

  • You need to escape the HTML in your Blade like so

    @if(isset($facebookpage))
        {!! $facebookpage->code !!}
    @endif