How to hide an image URL in laravel? so if you wish to hide the image URL from the image tage in the browser inspection, I will tell you how to remove the image URL, and instead of the image url, we will add base64 encode code for the show image in the laravel application.
Sometimes clients do not want to show the image URL from where to coming or want to hide the image file source URL form the URL or publically, that time this post will help you.
I have below made a code example that code will replace the image URL with base64 code and will show the image using this base64 code. so that our image URL will hide and not be able to see publically.
$path = Storage::disk('public')->url('profile/profile-image.jpg');
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
<img src="{{ $base64 }}" alt="image">
We always thanks to you for reading our blogs.
Dharmesh Chauhan
(Swapinfoway Founder)Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us
Haresh Chauhan
(Co-Founder)We Are Also Recommending You :
- [issue] Possible All Way To Change Asset Path And Add Public To Asset Path In Laravel
- Upayments Gateway Integration PHP - Laravel
- Laravel 6 Image Upload Tutorial
- Laravel Event Broadcast With Redis Socket.io Echo To Listen Real-Time Message
- Laravel 12 with React Integration Tutorial (Step-by-Step Guide 2026)
- collapse() Method | Laravel Collection Example
- intervention/image change image format laravel tutorial
- Laravel Remove index.php From URL
- Select2 ajax example
- Laravel One to One Eloquent Relationship Tutorial