get_oembed_response_data_rich( array $data, WP_Post $post, int $width, int $height ): array
- Since
- 4.4.0
- Source
wp-includes/embed.php:719
Compatibility
- WordPress
- since 4.4.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$dataarray- The response data.
$postWP_Post- The post object.
$widthint- The requested width.
$heightint- The calculated height.
Return value
array- The modified response data.
Performance profile
How much work a call to get_oembed_response_data_rich() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Heavy
- Scaling
- Constant
- Instructions
- 37–76
- Plugin surface
- None
- Called by
- 0
Reaches the database via get_post().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 79.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- querycontent query
get_post()one call below get_oembed_response_data_rich() - hookthird-party callbacks
apply_filters()one call below get_oembed_response_data_rich()
Further down the call graph this can also reach option, cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 8 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost get_oembed_response_data_rich() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!has_post_thumbnail() | 37–55 | absint(), absint(), get_post_embed_html(), has_post_thumbnail(), get_post_type() |
has_post_thumbnail() | 43–61 | absint(), absint(), get_post_embed_html(), has_post_thumbnail(), get_post_thumbnail_id(), get_post_type() |
!has_post_thumbnail() && wp_attachment_is_image() | 44–62 | absint(), absint(), get_post_embed_html(), has_post_thumbnail(), get_post_type(), wp_attachment_is_image() |
!has_post_thumbnail() && !wp_attachment_is_image() && !wp_attachment_is() | 46–64 | absint(), absint(), get_post_embed_html(), has_post_thumbnail(), get_post_type(), wp_attachment_is_image(), wp_attachment_is() |
has_post_thumbnail() && wp_attachment_is_image() | 50–68 | absint(), absint(), get_post_embed_html(), has_post_thumbnail(), get_post_thumbnail_id(), get_post_type(), wp_attachment_is_image() |
!has_post_thumbnail() && !wp_attachment_is_image() && wp_attachment_is() | 52–70 | absint(), absint(), get_post_embed_html(), has_post_thumbnail(), get_post_type(), wp_attachment_is_image(), wp_attachment_is(), get_post_thumbnail_id() |
has_post_thumbnail() && !wp_attachment_is_image() && !wp_attachment_is() | 52–70 | absint(), absint(), get_post_embed_html(), has_post_thumbnail(), get_post_thumbnail_id(), get_post_type(), wp_attachment_is_image(), wp_attachment_is() |
has_post_thumbnail() && !wp_attachment_is_image() && wp_attachment_is() | 58–76 | absint(), absint(), get_post_embed_html(), has_post_thumbnail(), get_post_thumbnail_id(), get_post_type(), wp_attachment_is_image(), wp_attachment_is(), get_post_thumbnail_id() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 79 instructions, 37–76 executed per call, 6 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 8
- absint()Converts a value to non-negative integer.
- get_post_embed_html()Retrieves the embed code for a specific post.
- has_post_thumbnail()Determines whether a post has an image attached.
- get_post_thumbnail_id()Retrieves the post thumbnail ID.
- get_post_type()Retrieves the post type of the current post or of a given post.
- wp_attachment_is_image()Determines whether an attachment is an image.
- wp_attachment_is()Verifies an attachment is of a given type.
- wp_get_attachment_image_src()Retrieves an image to represent an attachment.
Source code
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; } elseif ( wp_attachment_is( 'video', $post ) ) { $thumbnail_id = get_post_thumbnail_id( $post ); $data['type'] = 'video'; } } if ( $thumbnail_id ) { $thumbnail_src = wp_get_attachment_image_src( $thumbnail_id, array( $width, 0 ) ); if ( is_array( $thumbnail_src ) ) { $data['thumbnail_url'] = $thumbnail_src[0]; $data['thumbnail_width'] = $thumbnail_src[1]; $data['thumbnail_height'] = $thumbnail_src[2]; } } return $data;}Changelog
Introduced in 4.4.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, from
src/wp-includes/embed.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.