<?php

namespace Dispatch\Config;
use Dispatch\Functions\Filters as Filters;

class Media {

    protected $image_sizes;

    public function __construct() {

        $this->image_sizes = array(
            ['panel', 1920, 1200, true],
            ['panel-cta', 1920, 400, true],
            ['panel-tall', 960, 1200, true],
            ['panel-tall-nocrop', 960, 1200, false],
            ['card-single', 298, 188, true],
            ['card-double', 596, 376, true],
            ['onboarding', 640, 1020, true],
            ['gallery-thumbnail', 392, 222, true],
            // ['gallery-thumbnail', 786, 444, true],
            ['gallery-large', 1024, 2400, false],
        );

        add_filter( 'init', [$this, 'register'] );

        add_filter('intermediate_image_sizes_advanced', [$this, 'intermediate_image_sizes_advanced']);
    }

    public function register() {

        foreach( $this->image_sizes as $image_size ) {
            $this->register_image_size( $image_size );
        }
    }

    function intermediate_image_sizes_advanced( $sizes = array() ) {
        unset( $sizes['thumbnail']);
        unset( $sizes['medium']);
        unset( $sizes['medium_large']);
        unset( $sizes['large']);

        return $sizes; 
    }

    public function register_image_size( $image_size ) {
        add_image_size( $image_size[0], $image_size[1], $image_size[2], $image_size[3] );
    }



}


