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') }}
Related
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
This is for a small school assignment.
We are trying to create and deploy a search website of local cricket players.
I have everything running locally the only thing is I need to use is asset on my images to get them to deploy properly.
currently I have in my local
<img src="/images/{{$player['image']}}" class="playerimg">
I have tried concatenating it but to no avail.
The reason I have a variable $player is because we are pulling data from two tables and looping around the array.
Any help would be greatly appreciated
Edit: Solved Thank you all for your help ! code below
<img src="{{ asset('images/'.$player['image']) }}" class="playerimg">
Laravel - Helpers: asset()
https://laravel.com/docs/master/helpers#method-asset
<img src="{{ asset('images/'.$player['image']) }}" class="playerimg">
There are several ways to display the image.
I'm assuming index.php in public folder.
asset() Generates a URL to an application asset (code)
Use for files that are directly served such as CSS, images, javascript.
Only accepts a direct path.
{{ asset('images/'.$player['image']) }}
// http://www.example.com/public/images/abc.png
If you stored your image in storage folder then,
<img src="{{ storage_path('images/'.$player['image']) }}">
Make sure config.php should be configured properly for storage_path.
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"/>
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])!!}.
I have an problem with displaying my uploaded image to web/images when using the following line below while inside of the blog text or using a data fixture.
I've tested it by manually calling in the code to display the image inside of the Twig file but I want to use this in a fixture/entering it in the blog text to customize the size/alignment of the images for each post.
Can someone show me what's preventing the image from displaying?
Cheers!
This refuses to display image while in a fixture or inside blog text: (shows an outline of the proper sizing and alignment of image inside the blog text but not the image itself)
<img class="alignleft" src="{{ asset(['images/', news.image]|join) }}" alt="" width="290" height="275" />
Using a web link for an image works fine when in a fixture or when entering a blog text:
<img class="alignleft" src="http://www.example.com/example.jpg" alt="" width="290" height="275" />
Using autoescape false to display the blog text:
{% autoescape false %}
<p>{{ news.blog }}</p>
{% endautoescape %}
You're trying to render a string(variable) as a (sub-)template.
That's why twig isn't processing the {{ asset() }} function.
Auto-escaping is not what you're looking for as it doesn't enable processing of twig functions inside strings.
solution:
the template_from_string function
1.) Enable the Twig_Extension_StringLoader extension that comes bundled with twig in your config.yml
services:
# ...
twig.extension.stringloader:
class: Twig_Extension_StringLoader
tags:
- { name: twig.extension }
Now clear your cache using app/console cache:clear.
2.) If you have your template stored in a variable named news.blog you can now use the function as follows:
{{ include(template_from_string(news.blog)) }}
more information in the documentation: template_from_string