From f2444857eb1afc6f04345b2ede7587aa262e9d69 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Thu, 8 Oct 2015 23:08:40 +0000 Subject: [PATCH] Embeds: Combine the `oembed_minwidth` and `oembed_maxwidth` filters into one, similar to how the existing `oembed_defaults` works for width and height. See #32522. See #34227. git-svn-id: https://develop.svn.wordpress.org/trunk@34972 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/embed-functions.php | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/wp-includes/embed-functions.php b/src/wp-includes/embed-functions.php index dc4ce09a67..e238e2914b 100644 --- a/src/wp-includes/embed-functions.php +++ b/src/wp-includes/embed-functions.php @@ -524,27 +524,26 @@ function get_oembed_response_data( $post = null, $width ) { } /** - * Filter the allowed minimum width for the oEmbed response. + * Filter the allowed minimum and maximum widths for the oEmbed response. * * @since 4.4.0 * - * @param int $width The minimum width. Defaults to 200. - */ - $minwidth = apply_filters( 'oembed_minwidth', 200 ); - - /** - * Filter the allowed maximum width for the oEmbed response. + * @param array $min_max_width { + * Minimum and maximum widths for the oEmbed response. * - * @since 4.4.0 - * - * @param int $width The maximum width. Defaults to 600. + * @type int $min Minimum width. Default 200. + * @type int $max Maximum width. Default 600. + * } */ - $maxwidth = apply_filters( 'oembed_maxwidth', 600 ); + $min_max_width = apply_filters( 'oembed_min_max_width', array( + 'min' => 200, + 'max' => 600 + ) ); - if ( $width < $minwidth ) { - $width = $minwidth; - } else if ( $width > $maxwidth ) { - $width = $maxwidth; + if ( $width < $min_max_width['min'] ) { + $width = $min_max_width['min']; + } elseif ( $width > $min_max_width['max'] ) { + $width = $min_max_width['max']; } $height = ceil( $width / 16 * 9 );