From fb5b6170564b403944a8fbf8a4e6eb877b26a092 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 15 Jan 2018 19:43:30 +0000 Subject: [PATCH] Media: Bring consistency to `getimagesize()` error suppression. Props chasewg, joemcgill, jeremyfelt. Fixes #42480. git-svn-id: https://develop.svn.wordpress.org/trunk@42449 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/image.php | 6 +++--- src/wp-admin/includes/media.php | 6 +++--- .../endpoints/class-wp-rest-attachments-controller.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/wp-admin/includes/image.php b/src/wp-admin/includes/image.php index 4b66a5d36f..0f03e2ca42 100644 --- a/src/wp-admin/includes/image.php +++ b/src/wp-admin/includes/image.php @@ -357,7 +357,7 @@ function wp_read_image_metadata( $file ) { return false; } - list( , , $sourceImageType ) = getimagesize( $file ); + list( , , $sourceImageType ) = @getimagesize( $file ); /* * EXIF contains a bunch of data we'll probably never need formatted in ways @@ -386,10 +386,10 @@ function wp_read_image_metadata( $file ) { * as caption, description etc. */ if ( is_callable( 'iptcparse' ) ) { - getimagesize( $file, $info ); + @getimagesize( $file, $info ); if ( ! empty( $info['APP13'] ) ) { - $iptc = iptcparse( $info['APP13'] ); + $iptc = @iptcparse( $info['APP13'] ); // Headline, "A brief synopsis of the caption." if ( ! empty( $iptc['2#105'][0] ) ) { diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php index 03e949f16f..42584ee5c0 100644 --- a/src/wp-admin/includes/media.php +++ b/src/wp-admin/includes/media.php @@ -368,8 +368,8 @@ function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid $content .= ' ' . sprintf( __( 'Genre: %s.' ), $meta['genre'] ); } - // Use image exif/iptc data for title and caption defaults if possible. - } elseif ( 0 === strpos( $type, 'image/' ) && $image_meta = @wp_read_image_metadata( $file ) ) { + // Use image exif/iptc data for title and caption defaults if possible. + } elseif ( 0 === strpos( $type, 'image/' ) && $image_meta = wp_read_image_metadata( $file ) ) { if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) { $title = $image_meta['title']; } @@ -437,7 +437,7 @@ function media_handle_sideload( $file_array, $post_id, $desc = null, $post_data $content = ''; // Use image exif/iptc data for title and caption defaults if possible. - if ( $image_meta = @wp_read_image_metadata( $file ) ) { + if ( $image_meta = wp_read_image_metadata( $file ) ) { if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) { $title = $image_meta['title']; } diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php index 528a6ce0c6..30ddafc982 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php @@ -123,7 +123,7 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { $file = $file['file']; // use image exif/iptc data for title and caption defaults if possible - $image_meta = @wp_read_image_metadata( $file ); + $image_meta = wp_read_image_metadata( $file ); if ( ! empty( $image_meta ) ) { if ( empty( $request['title'] ) && trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {