Make WordPress Core


Ignore:
Timestamp:
09/06/2022 09:13:17 PM (2 years ago)
Author:
adamsilverstein
Message:

Media: Output WebP by default when uploading JPEGs.

Uploaded JPEGs will automatically be converted to WebP sub-sizes instead of JPEG, saving space and making sites faster.

The original JPEG upload is always retained and can be accessed by calling wp_get_original_image_url.

Props azaozz, flixos90.
Fixes #55443.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/media.php

    r54071 r54086  
    38443844    }
    38453845}
     3846
     3847/**
     3848 * Filters the default image output mapping.
     3849 *
     3850 * With this filter callback, WebP image files will be generated for certain JPEG source files.
     3851 *
     3852 * @since 6.1.0
     3853 *
     3854 * @param array $output_mapping Map of mime type to output format.
     3855 * @retun array The adjusted default output mapping.
     3856 */
     3857function wp_default_image_output_mapping( $output_mapping ) {
     3858    $output_mapping['image/jpeg'] = 'image/webp';
     3859    return $output_mapping;
     3860}
Note: See TracChangeset for help on using the changeset viewer.