Widgets: Apply the same container-constraining embed resizing logic from the Video widget to embeds in the Text widget.
See #40854, #39994. Built from https://develop.svn.wordpress.org/trunk@41779 git-svn-id: http://core.svn.wordpress.org/trunk@41613 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b6297d1866
commit
77a4574b96
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.9-beta1-41778';
|
||||
$wp_version = '4.9-beta1-41779';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
|
@ -290,12 +290,31 @@ class WP_Widget_Text extends WP_Widget {
|
|||
echo $args['before_title'] . $title . $args['after_title'];
|
||||
}
|
||||
|
||||
$text = preg_replace_callback( '#<[^>]*>#', array( $this, 'inject_video_max_width_style' ), $text );
|
||||
|
||||
?>
|
||||
<div class="textwidget"><?php echo $text; ?></div>
|
||||
<?php
|
||||
echo $args['after_widget'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject max-width and remove height for videos too constrained to fit inside sidebars on frontend.
|
||||
*
|
||||
* @since 4.9.0
|
||||
*
|
||||
* @see WP_Widget_Media_Video::inject_video_max_width_style()
|
||||
* @param array $matches Pattern matches from preg_replace_callback.
|
||||
* @return string HTML Output.
|
||||
*/
|
||||
public function inject_video_max_width_style( $matches ) {
|
||||
$html = $matches[0];
|
||||
$html = preg_replace( '/\sheight="\d+"/', '', $html );
|
||||
$html = preg_replace( '/\swidth="\d+"/', '', $html );
|
||||
$html = preg_replace( '/(?<=width:)\s*\d+px(?=;?)/', '100%', $html );
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles updating settings for the current Text widget instance.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue