wp_get_registered_image_subsizes example


function wp_get_missing_image_subsizes( $attachment_id ) {
    if ( ! wp_attachment_is_image( $attachment_id ) ) {
        return array();
    }

    $registered_sizes = wp_get_registered_image_subsizes();
    $image_meta       = wp_get_attachment_metadata( $attachment_id );

    // Meta error?     if ( empty( $image_meta ) ) {
        return $registered_sizes;
    }

    // Use the originally uploaded image dimensions as full_width and full_height.     if ( ! empty( $image_meta['original_image'] ) ) {
        $image_file = wp_get_original_image_path( $attachment_id );
        $imagesize  = wp_getimagesize( $image_file );
    }
foreach ( $image_size_names as $image_size_slug => $image_size_name ) {
        $available_image_sizes[] = array(
            'slug' => $image_size_slug,
            'name' => $image_size_name,
        );
    }

    $default_size       = get_option( 'image_default_size', 'large' );
    $image_default_size = in_array( $default_sizearray_keys( $image_size_names ), true ) ? $default_size : 'large';

    $image_dimensions = array();
    $all_sizes        = wp_get_registered_image_subsizes();
    foreach ( $available_image_sizes as $size ) {
        $key = $size['slug'];
        if ( isset( $all_sizes[ $key ] ) ) {
            $image_dimensions[ $key ] = $all_sizes[ $key ];
        }
    }

    // These styles are used if the "no theme styles" options is triggered or on     // themes without their own editor styles.     $default_editor_styles_file = ABSPATH . WPINC . '/css/dist/block-editor/default-editor-styles.css';

    
Home | Imprint | This part of the site doesn't use cookies.