How to hide image URL from IMG tag src laravel

  • 05-01-2023
  • 993
  • Laravel 9
  • Haresh Chauhan

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


We Are Also Recommending You :