diff options
Diffstat (limited to 'plugins/jetpack/class.jetpack-post-images.php')
-rw-r--r-- | plugins/jetpack/class.jetpack-post-images.php | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/plugins/jetpack/class.jetpack-post-images.php b/plugins/jetpack/class.jetpack-post-images.php index afdcacfa..5829fcc6 100644 --- a/plugins/jetpack/class.jetpack-post-images.php +++ b/plugins/jetpack/class.jetpack-post-images.php @@ -15,15 +15,17 @@ class Jetpack_PostImages { * If a slideshow is embedded within a post, then parse out the images involved and return them */ static function from_slideshow( $post_id, $width = 200, $height = 200 ) { + $images = array(); + $post = get_post( $post_id ); + if ( !empty( $post->post_password ) ) + return $images; if ( false === strpos( $post->post_content, '[slideshow' ) ) return false; // no slideshow - bail $permalink = get_permalink( $post->ID ); - $images = array(); - // Mechanic: Somebody set us up the bomb $old_post = $GLOBALS['post']; $GLOBALS['post'] = $post; @@ -79,15 +81,17 @@ class Jetpack_PostImages { * If a gallery is detected, then get all the images from it. */ static function from_gallery( $post_id ) { + $images = array(); + $post = get_post( $post_id ); + if ( !empty( $post->post_password ) ) + return $images; if ( false === strpos( $post->post_content, '[gallery' ) ) return false; // no gallery - bail $permalink = get_permalink( $post->ID ); - $images = array(); - // CATS: All your base are belong to us $old_post = $GLOBALS['post']; $GLOBALS['post'] = $post; @@ -145,6 +149,11 @@ class Jetpack_PostImages { * their dimensions are at or above a required minimum. */ static function from_attachment( $post_id, $width = 200, $height = 200 ) { + $images = array(); + + $post = get_post( $post_id ); + if ( !empty( $post->post_password ) ) + return $images; $post_images = get_posts( array( 'post_parent' => $post_id, // Must be children of post @@ -158,8 +167,6 @@ class Jetpack_PostImages { $permalink = get_permalink( $post_id ); - $images = array(); - foreach ( $post_images as $post_image ) { $meta = wp_get_attachment_metadata( $post_image->ID ); // Must be larger than 200x200 @@ -210,9 +217,12 @@ class Jetpack_PostImages { static function from_thumbnail( $post_id, $width = 200, $height = 200 ) { $images = array(); - if ( !function_exists( 'get_post_thumbnail_id' ) ) { + $post = get_post( $post_id ); + if ( !empty( $post->post_password ) ) + return $images; + + if ( !function_exists( 'get_post_thumbnail_id' ) ) return $images; - } $thumb = get_post_thumbnail_id( $post_id ); @@ -251,10 +261,12 @@ class Jetpack_PostImages { if ( is_numeric( $html_or_id ) ) { $post = get_post( $html_or_id ); - - if ( !$post ) + if ( empty( $post ) || !empty( $post->post_password ) ) return $images; + $html = $post->post_content; // DO NOT apply the_content filters here, it will cause loops + } else { + $html = $html_or_id; } if ( !$html ) |