Blade Component to Serve Images and Download Files
Published on by Paul Redmond
Smart makes it possible to serve images and download files from any location, including Laravel disks within a Laravel application. It enables resizing and caching images before sending them to the browser. Templates make it easy to preconfigure your settings to use them all over your site.
Smart enables easy image manipulation and downloads without any backend code:
- serve images from anywhere, this might be a public path , a private path or a Laravel disk
- resize images not only by defining height and width in the html image tag but by really resizing the content that is passed to the browser
- apply templates to images, change the settings for all images from one place
- automatically cache your images
- apply the full intervention/image API to an image
- download files from anywhere, this might be a public path , a private path or a Laravel disk
Using S3 as an example, here's how you can load an image from an S3 compatible storage disk:
<x-smart-image data-disk="s3" src="logos/mybrand.jpg"/>
Smart downloading is another unique feature this package offers, making it possible to download any image or file with a blade component. No need to program the backend portion of the code to provide file streams; this package handles all of that:
<x-smart-download src="{{ storage_path('manual.pdf') }}" target="_blank" />
The readme has plenty of examples to help you get started with this package. The author also has a video demonstration for those that want hands-on visual examples:
You can learn more about this package, get full installation instructions, and view the source code on GitHub.