Download the PHP package maccesar/laravel-glide-enhanced without Composer

On this page you can find all versions of the php package maccesar/laravel-glide-enhanced. 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-enhanced

Laravel Glide Enhanced

A Laravel package for dynamic image processing based on Spatie/Laravel-Glide.

Important Update (v3.x)

Version 3 supports Laravel 12–13 and PHP 8.2+. Image files are now isolated under the configured images.source_root (images by default), and public processing is rate-limited and strictly validated. See UPGRADE.md.

Previous Update (v2.x)

The default route prefix has changed from /img/ to /glide/ to avoid conflicts with other packages, especially laravel-dropzone-enhanced.

Before: https://your-site.com/img/path/image.jpg
Now: https://your-site.com/glide/path/image.jpg

See the UPGRADE.md file for migration instructions.

Features

Current Limitations

Installation

You can install the package via composer:

The package will automatically register its service provider and facade.

Then publish the configuration file:

Requirements

Configuration

The config/images.php file contains several configuration options:

Disk Configuration

The disk configuration selects a local Laravel filesystem. Sources are never read from its general root: with the defaults, photo.jpg resolves to storage/app/public/images/photo.jpg. Put watermarks in storage/app/public/watermarks. Remote disks such as S3 are not supported by the local image processor.

To retain another dedicated layout, configure its safe root explicitly:

Make sure the disk you specify is properly configured in your config/filesystems.php file.

Route Configuration

The routes section allows you to customize how the package registers its routes:

If you need to avoid conflicts with other packages, you can change the route prefix or disable the routes entirely and implement your own.

Basic Usage

Facades Available

The package provides two facades for your convenience:

Both facades provide identical functionality. We recommend using Img for cleaner, more readable code.

Image Processing URLs

HasImages Trait for Eloquent Models

HasImages Trait Reference

The HasImages trait provides comprehensive image processing methods for Eloquent models. Add this trait to any model that needs dynamic image processing capabilities.

Setup

Available Methods

Method Parameters Return Type Description
getImageUrl($type, $dimensions, $format, $watermark, $extraParams) string $type = 'default', string $dimensions = null, string $format = 'pjpg', string $watermark = null, array $extraParams = [] string Generate image URL with custom parameters
getImageWebpUrl($type, $params) string $type = 'default', array $params = [] string Generate WebP optimized image URL
getImagePreset($type, $preset) string $type = 'default', string $preset = 'thumbnail' string Generate image URL using predefined preset

Method Details

getImageUrl($type = 'default', $dimensions = null, $format = 'pjpg', $watermark = null, $extraParams = [])

Generate a custom image URL with specific parameters.

Parameters:

Example:

getImageWebpUrl($type = 'default', array $params = [])

Generate a WebP optimized image URL using the ImageProcessor facade.

Parameters:

Example:

getImagePreset($type = 'default', $preset = 'thumbnail')

Generate image URL using a predefined preset configuration.

Parameters:

Example:

Image Path Resolution

The trait automatically resolves image paths using these strategies:

  1. Custom methods: get{Type}ImagePath() method in your model
  2. Model properties: Direct property access ($this->{$type})
  3. Backward compatibility: For 'default' type, checks image, imagen, or foto properties

Example:

Image Presets

Laravel Glide Enhanced includes predefined presets for common image sizes and formats. These presets ensure consistent image processing across your application.

Available Presets

Preset Dimensions Format Fit Mode Quality Best Used For
thumbnail 150x150 WebP crop 85 Avatar images, small previews, gallery thumbnails
medium 400px width WebP max 85 Card images, product listings, blog post previews
large 800px width WebP max 85 Featured images, hero sections, detailed views
social 1200x630 JPG crop 85 Social media sharing (Open Graph, Twitter Cards)

Preset Configuration

The presets are defined in your config/images.php file:

Custom Presets

You can create your own presets by adding them to the configuration:

Using Custom Presets

Preset Best Practices

  1. thumbnail: Perfect for user avatars, small product images in lists
  2. medium: Ideal for product cards, blog post featured images
  3. large: Best for hero images, detailed product views
  4. social: Optimized for social media sharing (Facebook, Twitter, LinkedIn)

Performance Tips:

Responsive Images with srcset

The package provides a convenient way to generate srcset attributes for responsive images with different pixel densities:

Quick Reference

Common Use Cases

Most Used Glide Parameters

Parameter Values Description Example
w integer Width in pixels 'w' => 400
h integer Height in pixels 'h' => 300
fit crop, max, fill, stretch How image should fit dimensions 'fit' => 'crop'
fm webp, jpg, png, gif Output format 'fm' => 'webp'
q 0-100 Quality (lower = smaller file) 'q' => 90
blur 0-100 Blur effect 'blur' => 5
bright -100 to 100 Brightness adjustment 'bright' => 10
mark path Watermark image path 'mark' => 'logo.png'
markpos position Watermark position 'markpos' => 'bottom-right'

Fit Mode Reference

Applying Watermarks

You can apply watermarks to your images using the following parameters:

Important note: The watermark image must exist at the specified path within storage/app/public/. For example, if you use 'mark' => 'watermarks/logo.png', the file should be located at storage/app/public/watermarks/logo.png.

Usage in Blade Templates

Basic Image Display

Responsive Images

Product Gallery

Blog Post with Social Meta

E-commerce Product Card

Cache Cleaning

To clean the image cache, use the command:

To clean only images older than a specific number of days:

Components Registered

This package registers the following components in Laravel:

Troubleshooting

Common Issues

Images Not Processing

Problem: Images return original size instead of processed versions.

Solutions:

  1. Check that the images.php config file is published:

  2. Verify the disk configuration in config/images.php:

  3. Ensure images exist in the specified storage disk:

  4. Clear image cache:

Route Not Found Errors

Problem: URLs like /glide/storage/image.jpg return 404.

Solutions:

  1. Check that routes are enabled in config:

  2. Clear route cache:

  3. Verify routes are registered:

WebP Images Not Working

Problem: WebP images not displaying in some browsers.

Solutions:

  1. Provide fallback using <picture> element:

  2. Check server WebP support by testing a direct URL

Performance Issues

Problem: Slow image loading or processing.

Solutions:

  1. Implement image preloading for critical images:

  2. Use appropriate image formats:

    • WebP for modern browsers (smaller files)
    • JPG for photos with many colors
    • PNG for images with transparency
  3. Optimize cache settings in config/images.php:

  4. Use CDN for static assets in production

FAQ

Q: Can I use this with external storage like S3? A: Currently, the package works only with local storage disks (local and public). External storage support is planned for future versions.

Q: How do I create custom presets? A: Add them to your config/images.php file under the presets array. See the "Custom Presets" section above.

Q: Can I change the route prefix? A: Yes, modify the routes.prefix value in your config file. Remember to clear caches after changes.

Q: How do I disable the package routes? A: Set routes.enabled to false in your config file if you want to implement custom routing.

Q: What's the difference between getImageUrl() and getImageWebpUrl()? A: getImageWebpUrl() uses the ImageProcessor facade and accepts an array of parameters. getImageUrl() gives you full control over individual parameters including dimensions, format, and watermarks.

License

MIT

Credits

Developed by César Estrada (macCesar)


All versions of laravel-glide-enhanced with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^12.0|^13.0
spatie/laravel-glide Version ^3.6
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 maccesar/laravel-glide-enhanced contains the following files

Loading the files please wait ...