<?php

namespace ProudNerds\Plugins;

use ProudNerds\Trait\Initializable;
use Roots\WPConfig\Config;

class Timmy
{
    use Initializable;

    private function __construct()
    {
        if (!class_exists('\Timmy\Timmy')) {
            return;
        }

        if (defined('TIMMY') && !Config::get('TIMMY')) {
            return;
        }

        add_filter('timmy/sizes', [$this, 'addSizes']);
    }

    public function addSizes(array $sizes): array
    {
        $sizes['hero'] = [
            'resize' => [1100, 720, 'center'],
            'name' => 'Hero image',
            'srcset' => [
                [768, 400, 'center'],
                [480, 280, 'center'],
            ],
            'post_types' => ['all'],
            'webp' => true,
        ];

        $sizes['card'] = [
            'resize' => [570, 320, 'center'],
            'name' => 'Card image',
            'srcset' => [
                [456, 252, 'center'],
                [380, 210, 'center'],
            ],
            'post_types' => ['all'],
            'webp' => true,
        ];

        $sizes['logo_banner'] = [
            'resize' => [400, '', 'center'],
            'name' => 'Logo banner image',
            'post_types' => ['all'],
            'webp' => true,
        ];

        $sizes['two_images'] = [
            'resize' => [570, 580, 'center'],
            'name' => 'Two images',
            'post_types' => ['all'],
            'webp' => true,
        ];

        $sizes['banner_image'] = [
            'resize' => [1440, 545, 'center'],
            'name' => 'Banner image',
            'post_types' => ['all'],
            'webp' => true,
        ];

        return $sizes;
    }
}
