@@ -381,14 +381,10 @@ function set_post_thumbnail_size( $width = 0, $height = 0, $crop = false ) {
381381 * @return string HTML IMG element for given image attachment.
382382 */
383383function get_image_tag ( $ id , $ alt , $ title , $ align , $ size = 'medium ' ) {
384-
385384 list ( $ img_src , $ width , $ height ) = image_downsize ( $ id , $ size );
386- $ hwstring = image_hwstring ( $ width , $ height );
387-
388- $ title = $ title ? 'title=" ' . esc_attr ( $ title ) . '" ' : '' ;
389385
390386 $ size_class = is_array ( $ size ) ? implode ( 'x ' , $ size ) : $ size ;
391- $ class = ' align ' . esc_attr ( $ align ) . ' size-' . esc_attr ( $ size_class ) . ' wp-image-' . $ id ;
387+ $ class = " align { $ align} size-{ $ size_class} wp-image-{ $ id}" ;
392388
393389 /**
394390 * Filters the value of the attachment's image tag class attribute.
@@ -403,7 +399,19 @@ function get_image_tag( $id, $alt, $title, $align, $size = 'medium' ) {
403399 */
404400 $ class = apply_filters ( 'get_image_tag_class ' , $ class , $ id , $ align , $ size );
405401
406- $ html = '<img src=" ' . esc_url ( $ img_src ) . '" alt=" ' . esc_attr ( $ alt ) . '" ' . $ title . $ hwstring . 'class=" ' . $ class . '" /> ' ;
402+ $ html = WP_HTML ::render (
403+ <<<'HTML'
404+ <img src="</%src>" alt="</%alt>" title="</%title>" class="</%class>" height="</%height>" width="</%width>">
405+ HTML,
406+ array (
407+ 'alt ' => $ alt ,
408+ 'class ' => $ class ,
409+ 'height ' => (string ) $ height ,
410+ 'src ' => $ img_src ,
411+ 'title ' => empty ( $ title ) ? null : $ title ,
412+ 'width ' => (string ) $ width ,
413+ )
414+ );
407415
408416 /**
409417 * Filters the HTML content for the image tag.
@@ -3596,37 +3604,24 @@ function wp_video_shortcode( $attr, $content = '' ) {
35963604 $ html_atts = array (
35973605 'class ' => $ atts ['class ' ],
35983606 'id ' => sprintf ( 'video-%d-%d ' , $ post_id , $ instance ),
3599- 'width ' => absint ( $ atts ['width ' ] ),
3600- 'height ' => absint ( $ atts ['height ' ] ),
3601- 'poster ' => esc_url ( $ atts ['poster ' ] ),
3607+ 'width ' => ( string ) absint ( $ atts ['width ' ] ),
3608+ 'height ' => ( string ) absint ( $ atts ['height ' ] ),
3609+ 'poster ' => empty ( $ atts ['poster ' ] ) ? null : $ atts [ ' poster ' ] ,
36023610 'loop ' => wp_validate_boolean ( $ atts ['loop ' ] ),
36033611 'autoplay ' => wp_validate_boolean ( $ atts ['autoplay ' ] ),
36043612 'muted ' => wp_validate_boolean ( $ atts ['muted ' ] ),
3605- 'preload ' => $ atts ['preload ' ],
3613+ 'preload ' => empty ( $ atts[ ' preload ' ] ) ? null : $ attr ['preload ' ],
36063614 );
36073615
3608- // These ones should just be omitted altogether if they are blank.
3609- foreach ( array ( 'poster ' , 'loop ' , 'autoplay ' , 'preload ' , 'muted ' ) as $ a ) {
3610- if ( empty ( $ html_atts [ $ a ] ) ) {
3611- unset( $ html_atts [ $ a ] );
3612- }
3613- }
3614-
3615- $ attr_strings = array ();
3616- foreach ( $ html_atts as $ k => $ v ) {
3617- $ attr_strings [] = $ k . '=" ' . esc_attr ( $ v ) . '" ' ;
3618- }
3619-
36203616 $ html = '' ;
36213617
36223618 if ( 'mediaelement ' === $ library && 1 === $ instance ) {
36233619 $ html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]--> \n" ;
36243620 }
36253621
3626- $ html .= sprintf ( '<video %s controls="controls"> ' , implode ( ' ' , $ attr_strings ) );
3622+ $ html .= WP_HTML :: render ( '<video controls="controls" ...args > ' , array ( 'args ' => $ html_atts ) );
36273623
36283624 $ fileurl = '' ;
3629- $ source = '<source type="%s" src="%s" /> ' ;
36303625
36313626 foreach ( $ default_types as $ fallback ) {
36323627 if ( ! empty ( $ atts [ $ fallback ] ) ) {
@@ -3640,8 +3635,14 @@ function wp_video_shortcode( $attr, $content = '' ) {
36403635 } else {
36413636 $ type = wp_check_filetype ( $ atts [ $ fallback ], wp_get_mime_types () );
36423637 }
3643- $ url = add_query_arg ( '_ ' , $ instance , $ atts [ $ fallback ] );
3644- $ html .= sprintf ( $ source , $ type ['type ' ], esc_url ( $ url ) );
3638+
3639+ $ html .= WP_HTML ::render (
3640+ '<source type="</%source>" src="</%src>"> ' ,
3641+ array (
3642+ 'source ' => $ type ['type ' ],
3643+ 'src ' => add_query_arg ( '_ ' , $ instance , $ atts [ $ fallback ] ),
3644+ )
3645+ );
36453646 }
36463647 }
36473648
@@ -3657,11 +3658,16 @@ function wp_video_shortcode( $attr, $content = '' ) {
36573658 }
36583659 $ html .= '</video> ' ;
36593660
3660- $ width_rule = '' ;
3661- if ( ! empty ( $ atts ['width ' ] ) ) {
3662- $ width_rule = sprintf ( 'width: %dpx; ' , $ atts ['width ' ] );
3663- }
3664- $ output = sprintf ( '<div style="%s" class="wp-video">%s</div> ' , $ width_rule , $ html );
3661+ $ output = (
3662+ WP_HTML ::render (
3663+ '<div class="wp-video" style="</%width>"> ' ,
3664+ array (
3665+ 'width ' => ! empty ( $ atts ['width ' ] ) ? "width: {$ atts ['width ' ]}px; " : null ,
3666+ )
3667+ ) .
3668+ $ html .
3669+ '</div> '
3670+ );
36653671
36663672 /**
36673673 * Filters the output of the video shortcode.
0 commit comments