I want to display an image from my database, stored as a blob. The Blade file to view the picture is as follows.
<div class="col-lg-7">
<img src="{{ url('images/' . $id )}} "/>
</div>
I tried to replace with this code:
<img style="display:block;width:100%;height:100%;" src="{{ url('images/' . $id) }} " />
It shows the view in the page like this:
I use the following function in my web route to get the image.
// Get profile image
Route::get('images/{id}', function ($id) {
// Find the user
$item = App\Itemregistration::find($id);
// Return the image in the response with the correct MIME type
return response()->make($item->Picture, 200, array(
'Content-Type' => (new finfo(FILEINFO_MIME))->buffer($item->Picture)
));
});
Previously I was able to display the picture; the image is stored in the images folder. However, after a few developments in another area, suddenly I just noticed the picture could not be displayed. I had checked using URL (for example http://127.0.0.1:8000/images/210 ) the image is downloaded as an unknown file. I had compared the code with the previous version; it is the same. I am confused, what caused the problem.
Do anyone has an idea which way to identify the problem? Am I missing something or change something accidentally?Thanks.
Wouldn't it be easier to just render the image in the view directly, rather than define a function and then use it as you've done?
<img src="{{asset('your_image_folder_path'.$image->name)}}">
I see you are trying to access the image by it so maybe you can also do something like such:
public function methodName($id)
{
$image= YourImageModel::find($id);
return view('your_view_with_compacted_image_variable');
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.