Reputation: 33
I have a route that return an image, and i want the show the result of this route in a blade view, is there a way to directly call controller action or result of this route directly in the blade view ?
Thanks in advance.
Upvotes: 1
Views: 991
Reputation: 111829
You rather don't want to return image in blade. You should create separate controller action, that will return this image and link image src to this route, for example in controller:
public function image()
{
return $img = Image::make('image.jpg')->resize(800, 500)
->insert('sub_image.jpg', 'bottom-right', 10, 10) ->response();
}
then you create route to this controller action:
Route::get('my-image', 'MyController@image')->name('get-my-image');
and then in your Blade view you should link image src to this action:
<img src="{{ route('get-my-image') }}">
Upvotes: 2
Reputation: 17658
You can do this by giving the URL in src attribute of <img>
tag as:
<img src="{{ route('image.url') }}">
Upvotes: 1
Reputation: 2272
Well if it's an image, why don't you use an img
tag?
<img src="{{ route('my.image') }}" alt="My Image">
Upvotes: 1