1

I am saving my blog post as HTML into the database. An entry would look like this

<article>
    <h2>Simple Method to add WhatsApp button to Shopify Manually &#8211; Hard Coding</h2> 
    <figure>
        <img width="1024" height="366" src="{{ asset('storage/posts/screenshot-1024x366.jpg') }}" />
    </figure>
</article>

I display this in my template as. {!! $post->content !!}

Problem: Image is not displaying. Instead of displaying the actual asset link. It displays the directive {{ asset('storage/posts/whatsapp.jpg') }}

How can I escape the blade curly brace syntax and print the actual URL in the blade?

I want {{ asset('storage/posts/whatsapp.jpg') }} to display as http://127.0.0.1:8000/storage/posts/whatsapp.jpg

3
  • store url as it is instead of storing blade template in string content.So before printing in your template replace URL with APP_URL or best way is to place placeholders so you can replace easily Commented Mar 26, 2022 at 4:54
  • Also, worth looking @ stackoverflow.com/questions/39839080/… Commented Mar 26, 2022 at 5:11
  • Write your html view from DB into a temporary blade file, render it and return output string to blade file you wish to send to the user - wyattblogs.com/posts/… Commented Mar 26, 2022 at 5:25

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.