public static function imageSizes($size = false)
    {
        global $_wp_additional_image_sizes;
        $additionalSizes = $_wp_additional_image_sizes;

        $sizes = [];
        $imageSizes = get_intermediate_image_sizes();

        foreach($imageSizes as $imageSize)
        {
            if(in_array($imageSize, ['thumbnail', 'medium', 'large']))
            {
                $sizes[$imageSize] = (object) [
                    'name' => $imageSize,
                    'width' => get_option($imageSize . '_size_w'),
                    'height' => get_option($imageSize . '_size_h'),
                    'crop' => (bool) get_option($imageSize . '_crop')
                ];
            }
            elseif(isset($additionalSizes[$imageSize]))
            {
                $sizes[$imageSize] = (object) [
                    'name' => $imageSize,
                    'width' => $additionalSizes[$imageSize]['width'],
                    'height' => $additionalSizes[$imageSize]['height'],
                    'crop' => $additionalSizes[$imageSize]['crop']
                ];
            }
        }

        if($size)
        {
            if(isset($sizes[$size]))
            {
                return $sizes[$size];
            }
            else
            {
                return false;
            }
        }

        return $sizes;
    }
public static function imageSizes($size = false)
    {
        global $_wp_additional_image_sizes;
        $additionalSizes = $_wp_additional_image_sizes;

        $sizes = [];
        $imageSizes = get_intermediate_image_sizes();

        foreach($imageSizes as $imageSize)
        {
            if(in_array($imageSize, ['thumbnail', 'medium', 'large']))
            {
                $sizes[$imageSize] = (object) [
                    'name' => $imageSize,
                    'width' => get_option($imageSize . '_size_w'),
                    'height' => get_option($imageSize . '_size_h'),
                    'crop' => (bool) get_option($imageSize . '_crop')
                ];
            }
            elseif(isset($additionalSizes[$imageSize]))
            {
                $sizes[$imageSize] = (object) [
                    'name' => $imageSize,
                    'width' => $additionalSizes[$imageSize]['width'],
                    'height' => $additionalSizes[$imageSize]['height'],
                    'crop' => $additionalSizes[$imageSize]['crop']
                ];
            }
        }

        if($size)
        {
            if(isset($sizes[$size]))
            {
                return $sizes[$size];
            }
            else
            {
                return false;
            }
        }

        return $sizes;
    }
public static function imageSizes ( $ size = false ) { global $ _wp_additional_image_sizes ; $ additionalSizes = $ _wp_additional_image_sizes ; $ sizes = [ ] ; $ imageSizes = get_intermediate_image_sizes ( ) ; foreach ( $ imageSizes as $ imageSize ) { if ( in_array ( $ imageSize , [ 'thumbnail' , 'medium' , 'large' ] ) ) { $ sizes [ $ imageSize ] = ( object ) [ 'name' => $ imageSize , 'width' => get_option ( $ imageSize . '_size_w' ) , 'height' => get_option ( $ imageSize . '_size_h' ) , 'crop' => ( bool ) get_option ( $ imageSize . '_crop' ) ] ; } elseif ( isset ( $ additionalSizes [ $ imageSize ] ) ) { $ sizes [ $ imageSize ] = ( object ) [ 'name' => $ imageSize , 'width' => $ additionalSizes [ $ imageSize ] [ 'width' ] , 'height' => $ additionalSizes [ $ imageSize ] [ 'height' ] , 'crop' => $ additionalSizes [ $ imageSize ] [ 'crop' ] ] ; } } if ( $ size ) { if ( isset ( $ sizes [ $ size ] ) ) { return $ sizes [ $ size ] ; } else { return false ; } } return $ sizes ; }
Create an array of all image sizes and their meta data.

@param string $size Optionally return a specific image size only
Create an array of all image sizes and their meta data .