Download the PHP package tobimori/kirby-thumbhash without Composer

On this page you can find all versions of the php package tobimori/kirby-thumbhash. 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 kirby-thumbhash

Kirby ThumbHash

ThumbHash is an alternative image placeholder algorithm. Placeholders are represented by small ∼28 bytes hashes. It's similar to BlurHash but with the following advantages:

This plugin adds ThumbHash support to Kirby, allowing you to implement UX improvements such as progressive image loading or content-aware spoiler images like Mastodon.

If you rather want to use BlurHash in your application, feel free to use my kirby-blurhash plugin.

Under the hood, the heavy work gets done by a PHP implementation of ThumbHash by SRWieZ: SRWieZ/thumbhash

Requirements

Installation

Download

Download and copy this repository to /site/plugins/kirby-thumbhash.

Composer

Usage

Client-side decoding

$file->thumbhash()

Encodes the image with ThumbHash and returns ThumbHash as a string

The default implementation of ThumbHash expects the string to be decoded on the client-side.

This provides the most benefits, most notably including better color representation and smaller payload size, but requires the initial execution of such a library on the client-side, and thus is better used with a headless site or heavily makes use of client-side infinite scrolling/loading.

With an lazy-loading library like unlazy you can implement lazy-loading with client-side decoding easily by providing the thumbhash as attribute.

Server-side decoding

$file->thumbhashUri()

Encodes the image with ThumbHash, then decodes & rasterizes it. Finally returns it as a data URI which can be used without any client-side library.

In addition to simply outputting the ThumbHash string for usage on the client-side, this plugin also provides a server-side decoding option that allows you to output a base64-encoded image string, which can be used as a placeholder image without any client-side libraries, similar to Kirby Blurry Placeholder.

This is especially useful when you only have a few images on your site or don't want to go through the hassle of using a client-side library for outputting placeholders. Using this approach, you'll still get better color representation of the ThumbHash algorithm than with regularly downsizing an image, but image previews will still be about ~1kB large.

Cropped images

Kirby doesn't support file methods on cropped images, so you'll have to use the original image, and pass the ratio as attribute to the element to get the correct ThumbHash.

This is also supported by $file->thumbhash($ratio).

Working with static assets (using asset() helper)

All methods are available as asset methods since Kirby 3.9.2.

Read more about the asset() helper here.

Aliases

Options

Each method also allows you to specify the ratio and blur radius as options array.

Clear cache

The encoding cache is automatically cleared when an image gets replaced or updated, however you can also clear the cache manually with the clearCache static method:

This might be helpful when you use third party plugins to edit your images, and they do not trigger Kirby's internal file update hooks but instead have their own.

Options

Option Default Description
cache.decode true Enable decoding cache
cache.encode true Enable encoding cache
sampleMaxSize 100 Max width or height for smaller image that gets encoded (watch out for memory)
blurRadius 1 Default radius of the SVG blur filter applied decoded image, set to 0 for raw base64 png

Options allow you to fine tune the behaviour of the plugin. You can set them in your config.php file:

Credits

License

MIT License Copyright © 2023 Tobias Möritz


All versions of kirby-thumbhash with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0.0
getkirby/composer-installer Version ^1.2
srwiez/thumbhash Version ^1.1
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 tobimori/kirby-thumbhash contains the following files

Loading the files please wait ....