WordPress.org

Make WordPress Core

Changeset 51143


Ignore:
Timestamp:
06/14/2021 06:58:48 PM (4 months ago)
Author:
desrosj
Message:

Site Health: Display a list of file formats supported by the GD library.

This adds the list of file formats supported by the GD library to the Media Handling section in Site Health.

This will help site owners debug any issues they encounter as support for newer, more modern image formats is added (such as WebP in [50810]).

Follow up to [50817].
Props adamsilverstein, jorbin.
Fixes #53022.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-debug-data.php

    r50817 r51143  
    631631            'debug' => ( is_array( $gd ) ? $gd['GD Version'] : 'not available' ),
    632632        );
     633
     634        $gd_image_formats     = array();
     635        $gd_supported_formats = array(
     636            'GIF Create' => 'GIF',
     637            'JPEG'       => 'JPEG',
     638            'PNG'        => 'PNG',
     639            'WebP'       => 'WebP',
     640            'BMP'        => 'BMP',
     641            'AVIF'       => 'AVIF',
     642            'HEIF'       => 'HEIF',
     643            'TIFF'       => 'TIFF',
     644            'XPM'        => 'XPM',
     645        );
     646
     647        foreach ( $gd_supported_formats as $format_key => $format ) {
     648            $index = $format_key . ' Support';
     649            if ( isset( $gd[ $index ] ) && $gd[ $index ] ) {
     650                array_push( $gd_image_formats, $format );
     651            }
     652        }
     653
     654        if ( ! empty( $gd_image_formats ) ) {
     655            $info['wp-media']['fields']['gd_formats'] = array(
     656                'label' => __( 'GD supported file formats' ),
     657                'value' => implode( ', ', $gd_image_formats ),
     658            );
     659        }
    633660
    634661        // Get Ghostscript information, if available.
Note: See TracChangeset for help on using the changeset viewer.