Source file: _inc/lib/class.media-summary.php
View in GitHubParameters
- $data
-
(array) The calculated media summary data.
- $post_id
-
(int) The id of the post this data applies to.
Changelog
Since: Jetpack 4.4.0
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 );
how to use?
You can check the example above to see how to use the filter. The snippets you’ll create can be used by following the instructions here.