PHP code example of kaiseki / wp-image-sizes

1. Go to this page and download the library: Download kaiseki/wp-image-sizes 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/ */

    

kaiseki / wp-image-sizes example snippets


use Kaiseki\WordPress\ImageSizes\AspectRatio;
use Kaiseki\WordPress\ImageSizes\ImageSize;

return [
    'image_sizes' => [
        // Built-in sizes: [width, height, crop] or null to leave untouched.
        'thumbnail'    => [150, 150, true],
        'medium'       => [300, 300, false],
        'medium_large' => null,
        'large'        => [1024, 1024, false],

        // Additional custom sizes.
        'image_sizes' => [
            new ImageSize('hero', 1600, 900, true),
        ],

        // Generate one ImageSize per width from a name + aspect ratio.
        'aspect_ratios' => [
            (new AspectRatio('card-', 4, 3, []))->withWidths(320, 640, 960),
        ],

        // Override the 2560px "big image" threshold (or false to disable scaling).
        'big_image_threshold' => 2560,

        // Core/registered sizes to remove.
        'remove_sizes' => ['1536x1536', '2048x2048'],
    ],
];