@@ -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.
@@ -3603,37 +3611,24 @@ function wp_video_shortcode( $attr, $content = '' ) {
36033611 $ html_atts = array (
36043612 'class ' => $ atts ['class ' ],
36053613 'id ' => sprintf ( 'video-%d-%d ' , $ post_id , $ instance ),
3606- 'width ' => absint ( $ atts ['width ' ] ),
3607- 'height ' => absint ( $ atts ['height ' ] ),
3608- 'poster ' => esc_url ( $ atts ['poster ' ] ),
3614+ 'width ' => ( string ) absint ( $ atts ['width ' ] ),
3615+ 'height ' => ( string ) absint ( $ atts ['height ' ] ),
3616+ 'poster ' => empty ( $ atts ['poster ' ] ) ? null : $ atts [ ' poster ' ] ,
36093617 'loop ' => wp_validate_boolean ( $ atts ['loop ' ] ),
36103618 'autoplay ' => wp_validate_boolean ( $ atts ['autoplay ' ] ),
36113619 'muted ' => wp_validate_boolean ( $ atts ['muted ' ] ),
3612- 'preload ' => $ atts ['preload ' ],
3620+ 'preload ' => empty ( $ atts[ ' preload ' ] ) ? null : $ attr ['preload ' ],
36133621 );
36143622
3615- // These ones should just be omitted altogether if they are blank.
3616- foreach ( array ( 'poster ' , 'loop ' , 'autoplay ' , 'preload ' , 'muted ' ) as $ a ) {
3617- if ( empty ( $ html_atts [ $ a ] ) ) {
3618- unset( $ html_atts [ $ a ] );
3619- }
3620- }
3621-
3622- $ attr_strings = array ();
3623- foreach ( $ html_atts as $ k => $ v ) {
3624- $ attr_strings [] = $ k . '=" ' . esc_attr ( $ v ) . '" ' ;
3625- }
3626-
36273623 $ html = '' ;
36283624
36293625 if ( 'mediaelement ' === $ library && 1 === $ instance ) {
36303626 $ html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]--> \n" ;
36313627 }
36323628
3633- $ html .= sprintf ( '<video %s controls="controls"> ' , implode ( ' ' , $ attr_strings ) );
3629+ $ html .= WP_HTML :: render ( '<video controls="controls" ...args > ' , array ( 'args ' => $ html_atts ) );
36343630
36353631 $ fileurl = '' ;
3636- $ source = '<source type="%s" src="%s" /> ' ;
36373632
36383633 foreach ( $ default_types as $ fallback ) {
36393634 if ( ! empty ( $ atts [ $ fallback ] ) ) {
@@ -3647,8 +3642,14 @@ function wp_video_shortcode( $attr, $content = '' ) {
36473642 } else {
36483643 $ type = wp_check_filetype ( $ atts [ $ fallback ], wp_get_mime_types () );
36493644 }
3650- $ url = add_query_arg ( '_ ' , $ instance , $ atts [ $ fallback ] );
3651- $ html .= sprintf ( $ source , $ type ['type ' ], esc_url ( $ url ) );
3645+
3646+ $ html .= WP_HTML ::render (
3647+ '<source type="</%source>" src="</%src>"> ' ,
3648+ array (
3649+ 'source ' => $ type ['type ' ],
3650+ 'src ' => add_query_arg ( '_ ' , $ instance , $ atts [ $ fallback ] ),
3651+ )
3652+ );
36523653 }
36533654 }
36543655
@@ -3664,11 +3665,16 @@ function wp_video_shortcode( $attr, $content = '' ) {
36643665 }
36653666 $ html .= '</video> ' ;
36663667
3667- $ width_rule = '' ;
3668- if ( ! empty ( $ atts ['width ' ] ) ) {
3669- $ width_rule = sprintf ( 'width: %dpx; ' , $ atts ['width ' ] );
3670- }
3671- $ output = sprintf ( '<div style="%s" class="wp-video">%s</div> ' , $ width_rule , $ html );
3668+ $ output = (
3669+ WP_HTML ::render (
3670+ '<div class="wp-video" style="</%width>"> ' ,
3671+ array (
3672+ 'width ' => ! empty ( $ atts ['width ' ] ) ? "width: {$ atts ['width ' ]}px; " : null ,
3673+ )
3674+ ) .
3675+ $ html .
3676+ '</div> '
3677+ );
36723678
36733679 /**
36743680 * Filters the output of the video shortcode.
0 commit comments