Download the PHP package ralphjsmit/laravel-glide without Composer

On this page you can find all versions of the php package ralphjsmit/laravel-glide. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-glide

laravel-glide

Never worry about manually rescaling static images again!

Currently, it's almost a requirement to load images on websites in such a way that they are responsive and not unnecessarily big. This means that every image should be scaled down to a variety of sizes, so that browser on smaller screens don't have to download a large image unnecessarily. This technique is accomplished by using srcset and sizes attributes on each img tag.

However, if you receive a 3.000 x 2.000px image from your client, you don't want to put this into Figma or other tool, generate 5 versions, name them in a sensible way, manually put them in the correct public folder, etc. This is just a tremendous hassle, whereas usually you just want to drop in the original image in your project, refer to it via a src and be done with it. This package aims to solve this problem in a simple and sensible way.

Instead of manually needing to generate all these images, we can use an image generator like Glide. This package provides a simple way to reuse or scale images.

Installation

Run the following command to install the package:

You do not need to publish a config file or anything else.

Usage

In order to demonstrate this package's usage, we'll use the following example. Previously, you would include an image like this:

This loads the my-huge-image.png on it's full resolution on every screen size. With this package, you'd do this:

Under the hood, this will be converted to the following output:

If your browser receives the above code, it will determine the optimal image size. Say that your browser is 800px wide at a resolution of 2x, then it would be optimal to have an image of 1600px. Your browser will then look into the srcset and it will take the URL for the 1600px version (https://your-app.com/glide/img/my-huge-image.png?width=1600). The browser will then call this URL and Glide will generate the 1600px image version for the browser and return it.

Glide will cache all images, so that it doesn't have to generate the same image over and over again. Even on the first image, Glide will still be vary fast always.

Because the browser in this case only requests the 1600px, the other URLs are not called and therefore also not processed by Glide. This solution is therefore perfect, because it will only do the minimum amount of work.

Your image will automatically be upscaled to a maximum of 2x the resolution provided in your original image.

The glide()->src() function is even auto-completed if you use Laravel Idea to the files in your public-/asset-path.

Setting a maximum width

Say that your image is 2000px wide. However, you have displayed in such a way that it will at its biggest only be a 1000px wide. In that case, pass a second parameter to the glide()->src() function to set a maximum width:

This will output the image variations up to the last version that fits inside the maximum width, plus an image at exactly the maximum width, but not wider. Also, your original src will also inherit this maximum width:

Specifying a sizes attribute as well

You can provide a sizes attribute as well. This attribute is handy to tell the browser what width an image will approximately have at a certain breakpoint. You can give any value you want. This is an example of showing that on screens smaller than 500px, the image is approximately full-width, and on screens above (the default), it is approximately 50% of the screen width:

Which will result in:

Eager loading images

HTML allows for a native way to lazy load images if they are below the fold. This reduces the initial page size and speeds up the page load. Lazy loading for images is enabled by default for URLs outputted by Glide.

However, if you need to eager load an image, you can pass lazy: false to disable lazy loading for an image. You should only do this for images that are above the fold on initial page load, otherwise it will slow down your page unnecessarily.

Which will result in:

Clearing cache

If you want to clear the cache, you can call the following command:

This will empty the entire Glide cache. You can choose to put this in your deployment script on production if you every modify your current images (adding new images has no effect on the cache, they will just be generated anew). Another option is to only run this command when you actually modify an existing image and then run this command manually via SSH on the server in that situation.

Glide Configuration

Currently, the package does not provide configuration options and it just assumes sensible defaults.

Since it is geared at auto-generating versions for static images, it will assume the public_path()/asset() as root folder for the images.

The cache is positioned at the storage/framework/cache/glide folder.

Currently, it is not possible to modify these locations. However, that would not be so hard to implement. If you have a use case for this, please let me know via the issues or provide a PR.

Roadmap

I hope this package will be useful to you! If you have any ideas or suggestions on how to make it more useful, please let me know ([email protected]) or via the issues.

PRs are welcome, so feel free to fork and submit a pull request. I'll be happy to review your changes, think along and add them to the package.

Credits

This package was partially inspired by the archived flowframe/laravel-glide by Lars Klopstra.

General

🐞 If you spot a bug, please submit a detailed issue and I'll try to fix it as soon as possible.

🔐 If you discover a vulnerability, please e-mail [email protected].

🙌 If you want to contribute, please submit a pull request. All PRs will be fully credited. If you're unsure whether I'd accept your idea, feel free to contact me!

🙋‍♂️ Ralph J. Smit


All versions of laravel-glide with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/contracts Version ^10.0|^11.0
illuminate/http Version ^10.29|^11.0
illuminate/support Version ^10.29|^11.0
laravel/framework Version ^10.29|^11.0
league/glide-symfony Version ^2.0
spatie/laravel-package-tools Version ^1.14.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ralphjsmit/laravel-glide contains the following files

Loading the files please wait ....