@@ 276-319 (lines=44) @@ | ||
273 | $thumb = get_post_thumbnail_id( $post ); |
|
274 | } |
|
275 | ||
276 | if ( $thumb ) { |
|
277 | $meta = wp_get_attachment_metadata( $thumb ); |
|
278 | // Must be larger than requested minimums. |
|
279 | if ( ! isset( $meta['width'] ) || $meta['width'] < $width ) { |
|
280 | return $images; |
|
281 | } |
|
282 | if ( ! isset( $meta['height'] ) || $meta['height'] < $height ) { |
|
283 | return $images; |
|
284 | } |
|
285 | ||
286 | $too_big = ( ( ! empty( $meta['width'] ) && $meta['width'] > 1200 ) || ( ! empty( $meta['height'] ) && $meta['height'] > 1200 ) ); |
|
287 | ||
288 | if ( |
|
289 | $too_big && |
|
290 | ( |
|
291 | ( class_exists( 'Jetpack' ) && \Jetpack::is_module_active( 'photon' ) ) |
|
292 | || ( defined( 'IS_WPCOM' ) && \IS_WPCOM ) |
|
293 | ) |
|
294 | ) { |
|
295 | $img_src = wp_get_attachment_image_src( $thumb, array( 1200, 1200 ) ); |
|
296 | } else { |
|
297 | $img_src = wp_get_attachment_image_src( $thumb, 'full' ); |
|
298 | } |
|
299 | if ( ! is_array( $img_src ) ) { |
|
300 | // If wp_get_attachment_image_src returns false but we know that there should be an image that could be used. |
|
301 | // we try a bit harder and user the data that we have. |
|
302 | $thumb_post_data = get_post( $thumb ); |
|
303 | $img_src = array( $thumb_post_data->guid, $meta['width'], $meta['height'] ); |
|
304 | } |
|
305 | ||
306 | $url = $img_src[0]; |
|
307 | $images = array( |
|
308 | array( // Other methods below all return an array of arrays. |
|
309 | 'type' => 'image', |
|
310 | 'from' => 'thumbnail', |
|
311 | 'src' => $url, |
|
312 | 'src_width' => $img_src[1], |
|
313 | 'src_height' => $img_src[2], |
|
314 | 'href' => get_permalink( $thumb ), |
|
315 | 'alt_text' => self::get_alt_text( $thumb ), |
|
316 | ), |
|
317 | ); |
|
318 | ||
319 | } |
|
320 | ||
321 | if ( empty( $images ) && ( defined( 'IS_WPCOM' ) && \IS_WPCOM ) ) { |
|
322 | $meta_thumbnail = get_post_meta( $post_id, '_jetpack_post_thumbnail', true ); |
@@ 269-312 (lines=44) @@ | ||
266 | $thumb = get_post_thumbnail_id( $post ); |
|
267 | } |
|
268 | ||
269 | if ( $thumb ) { |
|
270 | $meta = wp_get_attachment_metadata( $thumb ); |
|
271 | // Must be larger than requested minimums |
|
272 | if ( ! isset( $meta['width'] ) || $meta['width'] < $width ) { |
|
273 | return $images; |
|
274 | } |
|
275 | if ( ! isset( $meta['height'] ) || $meta['height'] < $height ) { |
|
276 | return $images; |
|
277 | } |
|
278 | ||
279 | $too_big = ( ( ! empty( $meta['width'] ) && $meta['width'] > 1200 ) || ( ! empty( $meta['height'] ) && $meta['height'] > 1200 ) ); |
|
280 | ||
281 | if ( |
|
282 | $too_big && |
|
283 | ( |
|
284 | ( method_exists( 'Jetpack', 'is_module_active' ) && Jetpack::is_module_active( 'photon' ) ) || |
|
285 | ( defined( 'IS_WPCOM' ) && IS_WPCOM ) |
|
286 | ) |
|
287 | ) { |
|
288 | $img_src = wp_get_attachment_image_src( $thumb, array( 1200, 1200 ) ); |
|
289 | } else { |
|
290 | $img_src = wp_get_attachment_image_src( $thumb, 'full' ); |
|
291 | } |
|
292 | if ( ! is_array( $img_src ) ) { |
|
293 | // If wp_get_attachment_image_src returns false but we know that there should be an image that could be used. |
|
294 | // we try a bit harder and user the data that we have. |
|
295 | $thumb_post_data = get_post( $thumb ); |
|
296 | $img_src = array( $thumb_post_data->guid, $meta['width'], $meta['height'] ); |
|
297 | } |
|
298 | ||
299 | $url = $img_src[0]; |
|
300 | $images = array( |
|
301 | array( // Other methods below all return an array of arrays |
|
302 | 'type' => 'image', |
|
303 | 'from' => 'thumbnail', |
|
304 | 'src' => $url, |
|
305 | 'src_width' => $img_src[1], |
|
306 | 'src_height' => $img_src[2], |
|
307 | 'href' => get_permalink( $thumb ), |
|
308 | 'alt_text' => self::get_alt_text( $thumb ), |
|
309 | ), |
|
310 | ); |
|
311 | ||
312 | } |
|
313 | ||
314 | if ( empty( $images ) && ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ) { |
|
315 | $meta_thumbnail = get_post_meta( $post_id, '_jetpack_post_thumbnail', true ); |