From ff228a3bf671f5e0975859388a887b013ec56fcd Mon Sep 17 00:00:00 2001
From: Paul Biron <paul@sparrowhawkcomputing.com>
Date: Tue, 5 Sep 2017 08:16:44 -0600
Subject: [PATCH] add wp_get_image_extensions()

---
 src/wp-includes/media.php | 19 +++++++++++++++++++
 src/wp-includes/post.php  | 17 ++++++++---------
 2 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
index 9ec3f61..c8365f7 100644
--- a/src/wp-includes/media.php
+++ b/src/wp-includes/media.php
@@ -2398,6 +2398,25 @@ function wp_get_video_extensions() {
 }
 
 /**
+ * Returns a filtered list of WP-supported image formats.
+ *
+ * @since x.y.z
+ *
+ * @return array List of supported video formats.
+ */
+function wp_get_image_extensions() {
+	/**
+	 * Filters the list of supported image formats.
+	 *
+	 * @since z.y.z
+	 *
+	 * @param array $extensions An array of support image formats. Defaults are
+	 *                          'jpg', 'jpeg', 'jpe', 'gif', 'png'.
+	 */
+	return apply_filters( 'wp_image_extensions', array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' ) );
+}
+
+/**
  * Builds the Video shortcode output.
  *
  * This implements the functionality of the Video Shortcode for displaying
diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
index 904d11d..b1a6f69 100644
--- a/src/wp-includes/post.php
+++ b/src/wp-includes/post.php
@@ -5217,18 +5217,17 @@ function wp_attachment_is( $type, $post = null ) {
 	}
 
 	switch ( $type ) {
-	case 'image':
-		$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );
-		return in_array( $ext, $image_exts );
+		case 'image':
+			return in_array( $ext, wp_get_image_extensions() );
 
-	case 'audio':
-		return in_array( $ext, wp_get_audio_extensions() );
+		case 'audio':
+			return in_array( $ext, wp_get_audio_extensions() );
 
-	case 'video':
-		return in_array( $ext, wp_get_video_extensions() );
+		case 'video':
+			return in_array( $ext, wp_get_video_extensions() );
 
-	default:
-		return $type === $ext;
+		default:
+			return $type === $ext;
 	}
 }
 
-- 
2.7.0.windows.1

