| @@ -228,18 +228,27 @@ | ||
| 228 | 228 | * @param WP_Post $post Post. |
| 229 | 229 | * @return array Metadata. |
| 230 | 230 | */ |
| 231 | 231 | private static function add_image_to_metadata( $metadata, $post ) { |
| 232 | - $image = Images::get_image( | |
| 233 | - $post->ID, | |
| 234 | - array( | |
| 235 | - 'fallback_to_avatars' => true, | |
| 236 | - 'avatar_size' => 200, | |
| 237 | - // AMP already attempts these. | |
| 238 | - 'from_thumbnail' => false, | |
| 239 | - 'from_attachment' => false, | |
| 240 | - ) | |
| 232 | + $image_args = array( | |
| 233 | + 'fallback_to_avatars' => true, | |
| 234 | + 'avatar_size' => 200, | |
| 235 | + // AMP already attempts these. | |
| 236 | + 'from_thumbnail' => false, | |
| 237 | + 'from_attachment' => false, | |
| 241 | 238 | ); |
| 239 | + | |
| 240 | + // Every source left enabled above is parsed out of the body. | |
| 241 | + if ( \Automattic\Jetpack\SEO\Content_Gate::is_gated( $post ) ) { | |
| 242 | + $image_args += array( | |
| 243 | + 'from_slideshow' => false, | |
| 244 | + 'from_gallery' => false, | |
| 245 | + 'from_blocks' => false, | |
| 246 | + 'from_html' => false, | |
| 247 | + ); | |
| 248 | + } | |
| 249 | + | |
| 250 | + $image = Images::get_image( $post->ID, $image_args ); | |
| 242 | 251 | |
| 243 | 252 | if ( empty( $image ) ) { |
| 244 | 253 | return self::add_fallback_image_to_metadata( $metadata ); |
| 245 | 254 | } |