PHP code example of tobimori / kirby-thumbhash

1. Go to this page and download the library: Download tobimori/kirby-thumbhash library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tobimori / kirby-thumbhash example snippets


<img
  data-thumbhash="<?= $image->thumbhash() 

<img src="<?= $image->thumbhashUri() 

 $cropped = $original->crop(500, 400) 

asset('assets/image.jpg')->thumbhash();
asset('assets/image.jpg')->thumbhashUri();

$file->th(); // thumbhash()
$file->thUri(); // thumbhashUri()

$file->thumbhash([ 'ratio' => 16/9 ]); // will return thumbhash string, cropped to 16:9
$file->thumbhashUri([ 'blur' => 2 ]); // will return placeholder, encoded in an svg with blur filter
$file->thumbhashUri([ 'ratio' => 3/2, 'blur' => 0 ]); // will return placeholder as base64-encoded png without filter, cropped to 3:2



use tobimori\ThumbHash;

ThumbHash::clearCache($file);

return [
    'tobimori.thumbhash' => [
        'sampleMaxSize' => 100,
        'blurRadius' => 1,
    ],
];