From ff40a446265995d5c19e3ba9029c4f0bc8373a6b Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Sun, 8 Sep 2024 17:24:11 -0400 Subject: [PATCH 1/2] Change formatting of allowed extensions array --- includes/utils.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/includes/utils.php b/includes/utils.php index 3579a8d67..ef1b4772e 100644 --- a/includes/utils.php +++ b/includes/utils.php @@ -905,7 +905,18 @@ function process_media( $url, $post_id, $args = [] ) { * * @return {array} Media extensions to be processed. */ - $allowed_extensions = apply_filters( 'dt_allowed_media_extensions', array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' ), $url, $post_id ); + $allowed_extensions = apply_filters( + 'dt_allowed_media_extensions', + array( + 'jpg', + 'jpeg', + 'jpe', + 'gif', + 'png' + ), + $url, + $post_id + ); preg_match( '/[^\?]+\.(' . implode( '|', $allowed_extensions ) . ')\b/i', $url, $matches ); if ( ! $matches ) { $media_name = null; From 4a43d55a3ed1ef448993f58583e7f62906f3151e Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Sun, 8 Sep 2024 17:38:29 -0400 Subject: [PATCH 2/2] Add support for WebP, HEIC, and AVIF --- includes/utils.php | 5 ++++- tests/php/includes/common.php | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/utils.php b/includes/utils.php index ef1b4772e..4c2bc30e7 100644 --- a/includes/utils.php +++ b/includes/utils.php @@ -912,7 +912,10 @@ function process_media( $url, $post_id, $args = [] ) { 'jpeg', 'jpe', 'gif', - 'png' + 'png', + 'webp', + 'heic', + 'avif', ), $url, $post_id diff --git a/tests/php/includes/common.php b/tests/php/includes/common.php index d7ba845c9..e8c2a1645 100644 --- a/tests/php/includes/common.php +++ b/tests/php/includes/common.php @@ -266,6 +266,9 @@ function get_allowed_mime_types() { 'bmp' => 'image/bmp', 'tif|tiff' => 'image/tiff', 'ico' => 'image/x-icon', + 'webp' => 'image/webp', + 'heic' => 'image/heic', + 'avif' => 'image/avif', ]; }