Skip to content

lukaswhite/media-blurhash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Media BlurHash

A very simple package for Laravel that calculates the BlurHash of images added via Spatie's Laravel Media Library, which you can then use as placeh older images.

In other words, you can show this as a placeholder:

Example of a Blurhash


...from an image like this:

Example of a Blurhash


More information:

Installation

You can install the package via composer:

composer require lukaswhite/media-blurhash

Usage

IMPORTANT: Before running the migration, ensure you have run the media library package's migrations, as it adds a new column to the media table.

Publish the migration:

php artisan vendor:publish --provider="Lukaswhite\MediaBlurhash\MediaBlurhashServiceProvider" --tag=migrations

Run the migration:

php artisan migrate

Optionally publish the config:

php artisan vendor:publish --provider="Lukaswhite\MediaBlurhash\MediaBlurhashServiceProvider" --tag=config

This adds a blurhash column to the media table, which you can subsequently use to display a BlurHash, return in an API call etc.

By default, the package will calculate the BlurHash whenever an image is added via the media library. You can disable this in the config should you wish.

Manually Calculating the BlurHash

If you'd prefer to run the hashing process manually, you can either dispatch the package's job manually:

use Lukaswhite\MediaBlurhash\BlurhashMedia;

/** @var \Spatie\MediaLibrary\MediaCollections\Models\Media $media */
BlurhashMedia::dispatch($this->media);

Or, to use the package configuration's queue connection and/or name:

use Lukaswhite\MediaBlurhash\Utils\Dispatcher;

/** @var \Spatie\MediaLibrary\MediaCollections\Models\Media $media */
(new Dispatcher($media))->run();

Customising the Queue

You can tell the package to use a specific queue connection and/or name by publishing the config file and setting the appropriate values.

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email hello@lukaswhite.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

BlurHash support for Laravel Media Library

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages