2

I am using reactjs with the Laravel (Laravel-mix). I have my image in storage/app/public/images/slider-girl.png and referenced it on

 <img src="{require('/images/slider-girl.png')}" />

but not displaying the image.

However, I have tried to put the image in resources and public folder and I get the same response. I have tried options found here but nothing seems to work for me.

<img src={url('storage/app/public/images/slider-girl.png')} />

<img src="{require('/images/slider-girl.png')}" />

I expect the image be displayed.

1 Answer 1

7

Go to your webpack.mix.js, add

.setResourceRoot("/");

as illustrated below

mix.react('resources/js/app.js', 'public/js')
   .sass('resources/sass/app.scss', 'public/css')
   **.setResourceRoot("/");**

Then just reference it as follows:

<img src="/images/slider-girl.png" />

I hope it helps

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.