How do i get base64 JPG string as tiny placeholder instead of SVG for progressive image loading?
I need this because I am using this this package to work on a React Native app and React Native doesn't work well with SVG even as base64 string.
I am seeking for an implementation to help me get base64 JPG string instead of base64 SVG
Thanks For Your Help In Advance.
$path = $media->getPath();
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:application/' . $type . ';base64,' . base64_encode($data);
return response()->json(['type' => $type, 'file' => $base64]);
This is worked for me. Thanks!!!!
Most helpful comment