PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.7
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.7
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 All 506 releases
← All changes | _inc/lib/class.media-extractor.php +14 -10 13.8.3 → 16.3-a.7 View file →
@@ -5,8 +5,10 @@
5 5 *
6 6 * @package automattic/jetpack
7 7 */
8 8
9 +use Automattic\Jetpack\Post_Media\Images;
10 +
9 11 /**
10 12 * Class with methods to extract metadata from a post/page about videos, images, links, mentions embedded
11 13 * in or attached to the post/page.
12 14 *
@@ -81,9 +83,9 @@
81 83 if ( self::IMAGES & $what_to_extract ) {
82 84 $extracted = self::get_image_fields( $post, array(), $extract_alt_text );
83 85
84 86 // Turn off images so we can safely call extract_from_content() below.
85 - $what_to_extract = $what_to_extract - self::IMAGES;
87 + $what_to_extract -= self::IMAGES;
86 88 }
87 89
88 90 if ( function_exists( 'restore_current_blog' ) ) {
89 91 restore_current_blog();
@@ -346,9 +348,13 @@
346 348 list( $proto, $link_all_but_proto ) = explode( '://', $link_raw ); // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
347 349
348 350 // Check whether this "link" is really an embed.
349 351 foreach ( $oembed->providers as $matchmask => $data ) {
350 - list( $providerurl, $regex ) = $data; // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
352 + // Guard against malformed oEmbed providers.
353 + if ( ! isset( $data[0] ) ) {
354 + continue;
355 + }
356 + $regex = $data[1] ?? false;
351 357
352 358 // Turn the asterisk-type provider URLs into regex.
353 359 if ( ! $regex ) {
354 360 $matchmask = '#' . str_replace( '___wildcard___', '(.+)', preg_quote( str_replace( '*', '___wildcard___', $matchmask ), '#' ) ) . '#i';
@@ -382,9 +388,9 @@
382 388
383 389 /**
384 390 * Get image fields for matching images.
385 391 *
386 - * @uses Jetpack_PostImages
392 + * @uses Images
387 393 *
388 394 * @param WP_Post $post A post object.
389 395 * @param array $args Optional args, see defaults list for details.
390 396 * @param boolean $extract_alt_text Should alt_text be extracted, defaults to false.
@@ -407,9 +413,9 @@
407 413 $image_list = array();
408 414 $image_booleans = array();
409 415 $image_booleans['gallery'] = 0;
410 416
411 - $from_featured_image = Jetpack_PostImages::from_thumbnail( $post->ID, $args['width'], $args['height'] );
417 + $from_featured_image = Images::from_thumbnail( $post->ID, $args['width'], $args['height'] );
412 418 if ( ! empty( $from_featured_image ) ) {
413 419 if ( $extract_alt_text ) {
414 420 $image_list = array_merge( $image_list, self::reduce_extracted_images( $from_featured_image ) );
415 421 } else {
@@ -417,9 +423,9 @@
417 423 $image_list = array_merge( $image_list, $srcs );
418 424 }
419 425 }
420 426
421 - $from_slideshow = Jetpack_PostImages::from_slideshow( $post->ID, $args['width'], $args['height'] );
427 + $from_slideshow = Images::from_slideshow( $post->ID, $args['width'], $args['height'] );
422 428 if ( ! empty( $from_slideshow ) ) {
423 429 if ( $extract_alt_text ) {
424 430 $image_list = array_merge( $image_list, self::reduce_extracted_images( $from_slideshow ) );
425 431 } else {
@@ -427,9 +433,9 @@
427 433 $image_list = array_merge( $image_list, $srcs );
428 434 }
429 435 }
430 436
431 - $from_gallery = Jetpack_PostImages::from_gallery( $post->ID );
437 + $from_gallery = Images::from_gallery( $post->ID );
432 438 if ( ! empty( $from_gallery ) ) {
433 439 if ( $extract_alt_text ) {
434 440 $image_list = array_merge( $image_list, self::reduce_extracted_images( $from_gallery ) );
435 441 } else {
@@ -509,11 +515,9 @@
509 515 $retval['image'][] = $img;
510 516 }
511 517 }
512 518 $image_booleans['image'] = count( $retval['image'] );
513 - if ( ! empty( $image_booleans ) ) {
514 - $retval['has'] = $image_booleans;
515 - }
519 + $retval['has'] = $image_booleans;
516 520 return $retval;
517 521 } else {
518 522 return array();
519 523 }
@@ -529,9 +533,9 @@
529 533 * @return array Image URLs extracted from the HTML, stripped of query params and de-duped
530 534 */
531 535 public static function get_images_from_html( $html, $images_already_extracted, $extract_alt_text = false ) {
532 536 $image_list = $images_already_extracted;
533 - $from_html = Jetpack_PostImages::from_html( $html );
537 + $from_html = Images::from_html( $html );
534 538 // early return if no image in html.
535 539 if ( empty( $from_html ) ) {
536 540 return $image_list;
537 541 }