Changeset 24789
- Timestamp:
- 07/24/2013 05:52:49 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/media.php
r24777 r24789 857 857 858 858 $default_types = wp_get_audio_extensions(); 859 $defaults_atts = array( 'src' => '' ); 859 $defaults_atts = array( 860 'src' => '', 861 'loop' => '', 862 'autoplay' => '', 863 'preload' => 'none' 864 ); 860 865 foreach ( $default_types as $type ) 861 866 $defaults_atts[$type] = ''; … … 901 906 902 907 $atts = array( 903 sprintf( 'class="%s"', apply_filters( 'wp_audio_shortcode_class', 'wp-audio-shortcode' ) ), 904 sprintf( 'id="audio-%d-%d"', $post_id, $instances ), 908 'class' => apply_filters( 'wp_audio_shortcode_class', 'wp-audio-shortcode' ), 909 'id' => sprintf( 'audio-%d-%d', $post_id, $instances ), 910 'loop' => $loop, 911 'autoplay' => $autoplay, 912 'preload' => $preload, 905 913 ); 906 914 907 $html = sprintf( '<audio %s controls="controls" preload="none">', join( ' ', $atts ) ); 915 // These ones should just be omitted altogether if they are blank 916 foreach ( array( 'loop', 'autoplay', 'preload' ) as $a ) { 917 if ( empty( $atts[$a] ) ) 918 unset( $atts[$a] ); 919 } 920 921 $attr_strings = []; 922 foreach ( $atts as $k => $v ) { 923 $attr_strings[] = $k . '="' . esc_attr( $v ) . '"'; 924 } 925 926 $html = sprintf( '<audio %s controls="controls">', join( ' ', $attr_strings ) ); 908 927 909 928 $fileurl = ''; … … 958 977 $default_types = wp_get_video_extensions(); 959 978 $defaults_atts = array( 960 'src' => '', 961 'poster' => '', 962 'height' => 360, 963 'width' => empty( $content_width ) ? 640 : $content_width, 979 'src' => '', 980 'poster' => '', 981 'loop' => '', 982 'autoplay' => '', 983 'preload' => 'metadata', 984 'height' => 360, 985 'width' => empty( $content_width ) ? 640 : $content_width, 964 986 ); 965 987 … … 1019 1041 1020 1042 $atts = array( 1021 sprintf( 'class="%s"', apply_filters( 'wp_video_shortcode_class', 'wp-video-shortcode' ) ), 1022 sprintf( 'id="video-%d-%d"', $post_id, $instances ), 1023 sprintf( 'width="%d"', $width ), 1024 sprintf( 'height="%d"', $height ), 1043 'class' => apply_filters( 'wp_video_shortcode_class', 'wp-video-shortcode' ), 1044 'id' => sprintf( 'video-%d-%d', $post_id, $instances ), 1045 'width' => absint( $width ), 1046 'height' => absint( $height ), 1047 'poster' => esc_url( $poster ), 1048 'loop' => $loop, 1049 'autoplay' => $autoplay, 1050 'preload' => $preload, 1025 1051 ); 1026 1052 1027 if ( ! empty( $poster ) ) 1028 $atts[] = sprintf( 'poster="%s"', esc_url( $poster ) ); 1029 1030 $html = sprintf( '<video %s controls="controls" preload="none">', join( ' ', $atts ) ); 1053 // These ones should just be omitted altogether if they are blank 1054 foreach ( array( 'poster', 'loop', 'autoplay', 'preload' ) as $a ) { 1055 if ( empty( $atts[$a] ) ) 1056 unset( $atts[$a] ); 1057 } 1058 1059 $attr_strings = []; 1060 foreach ( $atts as $k => $v ) { 1061 $attr_strings[] = $k . '="' . esc_attr( $v ) . '"'; 1062 } 1063 1064 $html = sprintf( '<video %s controls="controls">', join( ' ', $attr_strings ) ); 1031 1065 1032 1066 $fileurl = ''; … … 1047 1081 $html .= '</video>'; 1048 1082 1083 $html = sprintf( '<div style="width: %dpx; max-width: 100%%;">%s</div>', $width, $html ); 1049 1084 return apply_filters( 'wp_video_shortcode', $html, $atts, $video, $post_id ); 1050 1085 }
Note: See TracChangeset
for help on using the changeset viewer.