PHP code example of arnoson / kirby-auto-srcset

1. Go to this page and download the library: Download arnoson/kirby-auto-srcset 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/ */

    

arnoson / kirby-auto-srcset example snippets


$srcset = $image->autoSrcset([
  'minWidth' => 300,
  'maxWidth' => 1024,
  'thumb' => [
    'format' => 'avif',
    'quality' => 80,
  ],
]);

// your-template.php
$srcset = $image->autoSrcset([
  'minWidth' => 300,
  'maxWidth' => 1000,

  // in kb
  'fileSizeStep' => 20,

  // The maximum number of images to be created.
  'maxSteps' => 10,

  // An optional ratio that is used to crop the image.
  'ratio' => 16 / 9,

  // Options to pass to kirby's `$file->thumb()` method.
  'thumb' => [
    'quality' => 80,
    'format' => 'jpeg',
    'crop' => 'center',
    // ...
  ],
]);

// config.php
return [
  'arnoson/kirby-auto-srcset' => [
    'minWidth' => 300,
    'maxWidth' => 1000,
    // ...
  ],
];