本文整理汇总了PHP中Jetpack_PostImages::from_gallery方法的典型用法代码示例。如果您正苦于以下问题:PHP Jetpack_PostImages::from_gallery方法的具体用法?PHP Jetpack_PostImages::from_gallery怎么用?PHP Jetpack_PostImages::from_gallery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jetpack_PostImages
的用法示例。
在下文中一共展示了Jetpack_PostImages::from_gallery方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_image_fields
/**
* @param $post A post object
* @param $args (array) Optional args, see defaults list for details
* @returns array Returns an array of all images meeting the specified criteria in $args
*
* Uses Jetpack Post Images
*/
private static function get_image_fields($post, $args = array())
{
$defaults = array('width' => 200, 'height' => 200);
$args = wp_parse_args($args, $defaults);
$image_list = array();
$image_booleans = array();
$image_booleans['gallery'] = 0;
$from_slideshow = Jetpack_PostImages::from_slideshow($post->ID, $args['width'], $args['height']);
if (!empty($from_slideshow)) {
$srcs = wp_list_pluck($from_slideshow, 'src');
$image_list = array_merge($image_list, $srcs);
}
$from_gallery = Jetpack_PostImages::from_gallery($post->ID);
if (!empty($from_gallery)) {
$srcs = wp_list_pluck($from_gallery, 'src');
$image_list = array_merge($image_list, $srcs);
$image_booleans['gallery']++;
// @todo This count isn't correct, will only every count 1
}
// @todo Can we check width/height of these efficiently? Could maybe use query args at least, before we strip them out
$image_list = Jetpack_Media_Meta_Extractor::get_images_from_html($post->post_content, $image_list);
return Jetpack_Media_Meta_Extractor::build_image_struct($image_list);
}
示例2: test_from_gallery_is_array
/**
* @author scotchfield
* @covers Jetpack_PostImages::from_gallery
* @since 3.2
*/
public function test_from_gallery_is_array()
{
$post_id = $this->factory->post->create(array('post_content' => '[gallery]'));
$images = Jetpack_PostImages::from_gallery($post_id);
$this->assertInternalType('array', $images);
}