Intervention Image
By using the Intervention Image package, you can call out the "encode()" method and pass in the "data-url" as the parameter to get the base64 value.
From the Laravel disk you can retrieve the image and pass it on to the Intervention Image "make()" method like below.
<?php use Intervention\Image\Facades\Image; $userPosterImage = User::first() ->poster_image; $imageLocation = \Storage::disk('public') ->url($userPosterImage); $imageInBase64 = (string) Image::make($imageLocation) ->encode('data-url');
<img src="{{ $imageInBase64 }}">
Leave a reply