How to get image url in laravel?

by giovanny.lueilwitz , in category: PHP Frameworks , a year ago

How to get image url in laravel?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by herminia_bruen , a year ago

@giovanny.lueilwitz 

To get the image URL in Laravel, you can use the asset() helper function.


Assuming you have an image stored in the public/images directory, you can generate the URL for the image like this:

1
$imageUrl = asset('images/image.jpg');


This will generate the full URL to the image, for example http://yourdomain.com/images/image.jpg.


Alternatively, if you are storing images in a different directory or a storage disk, you can use the Storage facade to get the URL:

1
$imageUrl = Storage::url('images/image.jpg');


This will generate the URL based on the disk configuration in your filesystems.php file.


You can then use the $imageUrl variable in your views to display the image.

Related Threads:

How to get image dimensions from url in discord.js?
How to get image dimensions from url in discord.js?
How to convert image url to base64 in laravel?
How to get an array from get url parameters in laravel?
How to get url parameter in controller in laravel?
How to get url path one level below in laravel?