apply_filters ( 'jetpack_media_summary_output', array $data, int $post_id )

Allow a theme or plugin to inspect and ultimately change the media summary.

Source file: _inc/lib/class.media-summary.php

View in GitHub

Parameters

$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 );

Have a note to contribute?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Comments

  1. provnads says:

    how to use?