laravel display image from database with blade - laravel

i just stored the path of a image that i uploaded into the database, however in the edit section of the form i want to show it and dont seem to find how is the right way to display it i have been trying with:
{{ HTML::image('imgs/picture.jpg') }} -> this one shows the path correctly BUT
using -> {!! Html::image('product_image') !!} doesnt display the path correctly if i use the chrome developer tools inspector i get this:
<img src="http://127.0.0.1:8000/product_image">
what am i doing wrong? what i want is to display the info (the path of the image) that is stored on the database.
thanks!

use Storage::url() ref link https://laravel.com/docs/8.x/filesystem#file-urls
{{ HTML::image(Storage::url('imgs/picture.jpg')) }}
//or
{{ HTML::image(Storage::url($product_image)) }} // here $product_image database path stored by Storage::put() function
it will generate url for laravel storage path like
<img src="http://127.0.0.1:8000/storage/imgs/picture.jpg"> it is correct path

Related

Display ID within QR Code

I'm trying to get the current survey id to show within my QR code, however it's only displaying
$survey->id
I'm sure there is something simple I'm missing (first laravel project). Any help would be appreciated.
Reference simple software QR
View
<img src="data:image/png;base64, {!! base64_encode(QrCode::format('png')->size(200)->generate('localhost:8000/survey/view/$survey->id')) !!} ">
Currently you are echoing $survey->id as a string, you want to use the value of said variable.
To do this you will need to remove it from the string and instead place it as the variable inside your url.
<img src="data:image/png;base64, {!! base64_encode(QrCode::format('png')->size(200)->generate('localhost:8000/survey/view/'.$survey->id)) !!} ">
Furthermore you might want to change the way your generate your link and instead use route names or the actions instead of the hardcoded local host, this might give trouble when deploying your application.

How to show image form another folder in laravel 5.2

I want to show picture form another folder. But why it's not working?
<img src="/picture/Capture.JPG" style="width:600px;height:400px">
My folder name is picture and image name is Capture.JPG
To print images ,css and js files correct path laravel have a default function asset()
Try this
<img src="{{ asset('picture/Capture.jpg') }}" style="height:400px;width:400px" >
I find my solution last night.
At first i create a folder in public folder name images. Then i store the picture. And the code formet is here.
<img src="{{url('/images/6.JPG')}}" alt="Image"/>

How to put image path in html::image() from database

I wanna put an image path in may laravel code like this
{!!Html::image({{$mdata->company_logo}},'logo',['width'=>60,'height'=>55])!!}
but {{$mdata->company_logo}} gives an error to html::image. I'm sure that image path from $mdata->company_logo has a valid data, namely the image path, because I can see it by using dd($data->company_logo).. But why html::image can't show the image...??
Thanks in advance.. :)
You shouldn't put the {{ }} around the $mdata->company_logo.
You are already inside a php block by using {!! !!} around Html::image().
Try {!!Html::image($mdata->company_logo,'logo',['width'=>60,'height'=>55])!!}.

Can't Display image in a webpage laravel 4

I have a image in the public/images folder.I want to show this image in my webpage and I am trying like this
{{ HTML::image('public/images/20140208-IMG_2538.jpg') }}
But I cant see my image on my webpage.Instead It shows a broken image icon.What can i do can anyone suggest?
The HTML::image() expects a path that is relative to public. Try this:
{{ HTML::image('images/20140208-IMG_2538.jpg') }}

Form::password in Laravel Blade Templates

I was trying to create a password field in the form in Laravel Blade templates but the output doesn't let me enter anything and it's not showing any placeholder either. The code doesn't cause any error.
Form:
{{ Form::open(array('class'=> 'forming')) }}
{{ Form::text('username','Username',array('class' => 'insi')); }}<br>
{{ Form::password('password',array('placeholder'=>'Password','class' => 'insi')); }}
{{ Form::close() }}
and the output is like that. Any help?
Second Input form is for password.
We are not seeing your generated HTML, but usually those problems are related to your HTML. For instance, you are using a CSS class 'insi', which may not letting you see the password characters.
To do a test remove/disable your CSS files from your main HTML and it probably will work fine.

Resources