Allow a theme or plugin to inspect and ultimately change the media summary.
Parameters
- $data
array The calculated media summary data.
- $post_id
int The id of the post this data applies to.
Changelog
- Introduced in Jetpack 4.4.0
How to use this hook
Notes
In the example below, we’ll force Jetpack to return a “Video” type as soon as there is a video in the post, and even if there is a lot of text as well.
/**
* Overwrite the type of post returned by Jetpack for Video posts.
*
* By default, Jetpack will consider a post a "Video" post
* if it has less than 3 paragraphs of text
* and of course an embedded video.
* Let's change that. As long as there is a video, it's a video type.
*
* @param array $data The calculated media summary data.
* @param int $post_id The id of the post this data applies to.
*/
function jeherve_custom_video_type( $data, $post_id ) {
// Is there at least one video in the post?
if ( 0 != $data['count']['video'] && ! empty( $data['video'] ) ) {
// Let's make the post type "video".
$data['type'] = 'video';
}
return $data;
}
add_filter( 'jetpack_media_summary_output', 'jeherve_custom_video_type', 10, 2 );