wp_embed_handler_video

函数
wp_embed_handler_video ( $matches, $attr, $url, $rawattr )
参数
  • (array) $matches The RegEx matches from the provided regex when calling wp_embed_register_handler().
    Required:
  • (array) $attr Embed attributes.
    Required:
  • (string) $url The original URL that was matched by the regex.
    Required:
  • (array) $rawattr The original unmodified attributes.
    Required:
返回值
  • (string) The embed HTML.
定义位置
相关方法
wp_embed_handler_googlevideowp_embed_handler_audiowp_embed_handler_youtubewp_oembed_add_providermedia_handle_sideload
引入
3.6.0
弃用
-

wp_embed_handler_video: 这个函数是一个回调函数,用于处理WordPress中的视频嵌入: 当用户在一个文章或页面中嵌入视频时,这个函数被调用来处理嵌入代码。

视频嵌入处理程序的回调。

function wp_embed_handler_video( $matches, $attr, $url, $rawattr ) {
	$dimensions = '';
	if ( ! empty( $rawattr['width'] ) && ! empty( $rawattr['height'] ) ) {
		$dimensions .= sprintf( 'width="%d" ', (int) $rawattr['width'] );
		$dimensions .= sprintf( 'height="%d" ', (int) $rawattr['height'] );
	}
	$video = sprintf( '[ video %s src="%s" / ]', $dimensions, esc_url( $url ) );

	/**
	 * Filters the video embed output.
	 *
	 * @since 3.6.0
	 *
	 * @param string $video   Video embed output.
	 * @param array  $attr    An array of embed attributes.
	 * @param string $url     The original URL that was matched by the regex.
	 * @param array  $rawattr The original unmodified attributes.
	 */
	return apply_filters( 'wp_embed_handler_video', $video, $attr, $url, $rawattr );
}

常见问题

FAQs
查看更多 >