protected function _generate_related_post_image_params($post_id)
{
$options = $this->get_options();
$image_params = array('src' => '', 'width' => 0, 'height' => 0);
if (!$options['show_thumbnails']) {
return $image_params;
}
/**
* Filter the size of the Related Posts images.
*
* @module related-posts
*
* @since 2.8.0
*
* @param array array( 'width' => 350, 'height' => 200 ) Size of the images displayed below each Related Post.
*/
$thumbnail_size = apply_filters('jetpack_relatedposts_filter_thumbnail_size', array('width' => 350, 'height' => 200));
if (!is_array($thumbnail_size)) {
$thumbnail_size = array('width' => (int) $thumbnail_size, 'height' => (int) $thumbnail_size);
}
// Try to get post image
if (class_exists('Jetpack_PostImages')) {
$img_url = '';
$post_image = Jetpack_PostImages::get_image($post_id, $thumbnail_size);
if (is_array($post_image)) {
$img_url = $post_image['src'];
} elseif (class_exists('Jetpack_Media_Summary')) {
$media = Jetpack_Media_Summary::get($post_id);
if (is_array($media) && !empty($media['image'])) {
$img_url = $media['image'];
}
}
if (!empty($img_url)) {
$image_params['width'] = $thumbnail_size['width'];
$image_params['height'] = $thumbnail_size['height'];
$image_params['src'] = Jetpack_PostImages::fit_image_url($img_url, $thumbnail_size['width'], $thumbnail_size['height']);
}
}
return $image_params;
}