get_intermediate_image_sizes example

$old_backup_sizes = $backup_sizes;
    $restored         = false;
    $msg              = new stdClass();

    if ( ! is_array( $backup_sizes ) ) {
        $msg->error = __( 'Cannot load image metadata.' );
        return $msg;
    }

    $parts         = pathinfo( $file );
    $suffix        = time() . rand( 100, 999 );
    $default_sizes = get_intermediate_image_sizes();

    if ( isset( $backup_sizes['full-orig'] ) && is_array( $backup_sizes['full-orig'] ) ) {
        $data = $backup_sizes['full-orig'];

        if ( $parts['basename'] != $data['file'] ) {
            if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) {

                // Delete only if it's an edited image.                 if ( preg_match( '/-e[0-9]{13}\./', $parts['basename'] ) ) {
                    wp_delete_file( $file );
                }
            }
'default'           => array(),
                'sanitize_callback' => 'wp_parse_id_list',
            ),
            'columns'        => array(
                'type'    => 'integer',
                'default' => 3,
                'minimum' => 1,
                'maximum' => 9,
            ),
            'size'           => array(
                'type'    => 'string',
                'enum'    => array_merge( get_intermediate_image_sizes(), array( 'full', 'custom' ) ),
                'default' => 'thumbnail',
            ),
            'link_type'      => array(
                'type'                  => 'string',
                'enum'                  => array( 'post', 'file', 'none' ),
                'default'               => 'post',
                'media_prop'            => 'link',
                'should_preview_update' => false,
            ),
            'orderby_random' => array(
                'type'                  => 'boolean',
                

function wp_get_registered_image_subsizes() {
    $additional_sizes = wp_get_additional_image_sizes();
    $all_sizes        = array();

    foreach ( get_intermediate_image_sizes() as $size_name ) {
        $size_data = array(
            'width'  => 0,
            'height' => 0,
            'crop'   => false,
        );

        if ( isset( $additional_sizes[ $size_name ]['width'] ) ) {
            // For sizes added by plugins and themes.             $size_data['width'] = (int) $additional_sizes[ $size_name ]['width'];
        } else {
            // For default sizes set in options.

    public function get_instance_schema() {
        return array_merge(
            array(
                'size'              => array(
                    'type'        => 'string',
                    'enum'        => array_merge( get_intermediate_image_sizes(), array( 'full', 'custom' ) ),
                    'default'     => 'medium',
                    'description' => __( 'Size' ),
                ),
                'width'             => array( // Via 'customWidth', only when size=custom; otherwise via 'width'.                     'type'        => 'integer',
                    'minimum'     => 0,
                    'default'     => 0,
                    'description' => __( 'Width' ),
                ),
                'height'            => array( // Via 'customHeight', only when size=custom; otherwise via 'height'.                     'type'        => 'integer',
                    
Home | Imprint | This part of the site doesn't use cookies.