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
|
b
|
function wp_get_video_extensions() { |
2398 | 2398 | } |
2399 | 2399 | |
2400 | 2400 | /** |
| 2401 | * Returns a filtered list of WP-supported image formats. |
| 2402 | * |
| 2403 | * @since x.y.z |
| 2404 | * |
| 2405 | * @return array List of supported video formats. |
| 2406 | */ |
| 2407 | function wp_get_image_extensions() { |
| 2408 | /** |
| 2409 | * Filters the list of supported image formats. |
| 2410 | * |
| 2411 | * @since z.y.z |
| 2412 | * |
| 2413 | * @param array $extensions An array of support image formats. Defaults are |
| 2414 | * 'jpg', 'jpeg', 'jpe', 'gif', 'png'. |
| 2415 | */ |
| 2416 | return apply_filters( 'wp_image_extensions', array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' ) ); |
| 2417 | } |
| 2418 | |
| 2419 | /** |
2401 | 2420 | * Builds the Video shortcode output. |
2402 | 2421 | * |
2403 | 2422 | * 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
|
b
|
function wp_attachment_is( $type, $post = null ) { |
5217 | 5217 | } |
5218 | 5218 | |
5219 | 5219 | switch ( $type ) { |
5220 | | case 'image': |
5221 | | $image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' ); |
5222 | | return in_array( $ext, $image_exts ); |
| 5220 | case 'image': |
| 5221 | return in_array( $ext, wp_get_image_extensions() ); |
5223 | 5222 | |
5224 | | case 'audio': |
5225 | | return in_array( $ext, wp_get_audio_extensions() ); |
| 5223 | case 'audio': |
| 5224 | return in_array( $ext, wp_get_audio_extensions() ); |
5226 | 5225 | |
5227 | | case 'video': |
5228 | | return in_array( $ext, wp_get_video_extensions() ); |
| 5226 | case 'video': |
| 5227 | return in_array( $ext, wp_get_video_extensions() ); |
5229 | 5228 | |
5230 | | default: |
5231 | | return $type === $ext; |
| 5229 | default: |
| 5230 | return $type === $ext; |
5232 | 5231 | } |
5233 | 5232 | } |
5234 | 5233 | |