WordPress.org

Make WordPress Core

Ticket #42695: 42695.diff

File 42695.diff, 1.2 KB (added by audrasjb, 4 years ago)

Avoid to strip dimensions from iframes in text widget embed logic

  • src/wp-includes/widgets/class-wp-widget-text.php

    diff --git a/src/wp-includes/widgets/class-wp-widget-text.php b/src/wp-includes/widgets/class-wp-widget-text.php
    index 36b05b3..4ba8061 100644
    a b class WP_Widget_Text extends WP_Widget { 
    340340         */
    341341        public function inject_video_max_width_style( $matches ) {
    342342                $html = $matches[0];
     343                preg_match( '@height="([^"]+)"@' , $html, $match_height );
     344                preg_match( '@width="([^"]+)"@' , $html, $match_width );
     345                $height = array_pop( $match_height );
     346                $width = array_pop( $match_width );
     347                if ( ! empty ( $height ) ) {
     348                        $html = preg_replace( '/\sheight="\d+"/', 'data-placeholder-height="' . $height . '"/', $html );
     349                }
     350                if ( ! empty ( $width ) ) {
     351                        $html = preg_replace( '/\swidth="\d+"/', 'data-placeholder-width="' . $width . '"/', $html );
     352                }
    343353                $html = preg_replace( '/\sheight="\d+"/', '', $html );
    344354                $html = preg_replace( '/\swidth="\d+"/', '', $html );
    345355                $html = preg_replace( '/(?<=width:)\s*\d+px(?=;?)/', '100%', $html );
     356                $html = str_replace( 'data-placeholder-height', 'height', $html );
     357                $html = str_replace( 'data-placeholder-width', 'width', $html );
    346358                return $html;
    347359        }
    348360