^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云2核2g仅需86元/年

wordpress函数get_oembed_response_data_rich()用法示例

get_oembed_response_data_rich( array $data,  WP_Post $post,  int $width,  int $height )

Filters the oEmbed response data to return an iframe embed code.


描述


参数

$data

(array)
(Required)
The response data.

新用户2核2g仅需86元/年    领取1153套模板    免费cdn流量包    ¥3188礼包

$post

(WP_Post)
(Required)
The post object.

$width

(int)
(Required)
The requested width.

$height

(int)
(Required)
The calculated height.


返回值

(array) The modified response data.


源代码

File: wp-includes/embed.php

function get_oembed_response_data_rich( $data, $post, $width, $height ) {
	$data['width']  = absint( $width );
	$data['height'] = absint( $height );
	$data['type']   = 'rich';
	$data['html']   = get_post_embed_html( $width, $height, $post );

	// Add post thumbnail to response if available.
	$thumbnail_id = false;

	if ( has_post_thumbnail( $post->ID ) ) {
		$thumbnail_id = get_post_thumbnail_id( $post->ID );
	}

	if ( 'attachment' === get_post_type( $post ) ) {
		if ( wp_attachment_is_image( $post ) ) {
			$thumbnail_id = $post->ID;
		} else if ( wp_attachment_is( 'video', $post ) ) {
			$thumbnail_id = get_post_thumbnail_id( $post );
			$data['type'] = 'video';
		}
	}

	if ( $thumbnail_id ) {
		list( $thumbnail_url, $thumbnail_width, $thumbnail_height ) = wp_get_attachment_image_src( $thumbnail_id, array( $width, 99999 ) );
		$data['thumbnail_url']    = $thumbnail_url;
		$data['thumbnail_width']  = $thumbnail_width;
		$data['thumbnail_height'] = $thumbnail_height;
	}

	return $data;
}

更新日志

Version 描述
4.4.0 Introduced.

相关函数

Uses

  • wp-includes/embed.php:
    get_post_embed_html()
  • wp-includes/post.php:
    wp_attachment_is()
  • wp-includes/functions.php:
    absint()
  • wp-includes/post-thumbnail-template.php:
    has_post_thumbnail()
  • wp-includes/post-thumbnail-template.php:
    get_post_thumbnail_id()
  • wp-includes/media.php:
    wp_get_attachment_image_src()
  • wp-includes/post.php:
    wp_attachment_is_image()
  • wp-includes/post.php:
    get_post_type()
  • Show 3 more uses


让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈