from_slideshow() static public method

If a slideshow is embedded within a post, then parse out the images involved and return them
static public from_slideshow ( $post_id, $width = 200, $height = 200 )
 /**
  * @author scotchfield
  * @covers Jetpack_PostImages::from_slideshow
  * @since 3.2
  */
 public function test_from_slideshow_is_array()
 {
     require_once plugin_dir_path(realpath(dirname(__FILE__) . '/../../modules/shortcodes/slideshow.php')) . 'slideshow.php';
     $slideshow = new Jetpack_Slideshow_Shortcode();
     $post_id = $this->factory->post->create(array('post_content' => '[slideshow]'));
     $images = Jetpack_PostImages::from_slideshow($post_id);
     $this->assertInternalType('array', $images);
 }
示例#2
0
 /**
  * @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);
 }