@@ -93,7 +93,7 @@ function wp_get_missing_image_subsizes( $attachment_id ) {
9393 // Use the originally uploaded image dimensions as full_width and full_height.
9494 if ( ! empty ( $ image_meta ['original_image ' ] ) ) {
9595 $ image_file = wp_get_original_image_path ( $ attachment_id );
96- $ imagesize = @ getimagesize ( $ image_file );
96+ $ imagesize = wp_getimagesize ( $ image_file );
9797 }
9898
9999 if ( ! empty ( $ imagesize ) ) {
@@ -224,7 +224,7 @@ function _wp_image_meta_replace_original( $saved_data, $original_file, $image_me
224224 * @return array The image attachment meta data.
225225 */
226226function wp_create_image_subsizes ( $ file , $ attachment_id ) {
227- $ imagesize = @ getimagesize ( $ file );
227+ $ imagesize = wp_getimagesize ( $ file );
228228
229229 if ( empty ( $ imagesize ) ) {
230230 // File is not an image.
@@ -687,7 +687,7 @@ function wp_read_image_metadata( $file ) {
687687 return false ;
688688 }
689689
690- list ( , , $ image_type ) = @ getimagesize ( $ file );
690+ list ( , , $ image_type ) = wp_getimagesize ( $ file );
691691
692692 /*
693693 * EXIF contains a bunch of data we'll probably never need formatted in ways
@@ -716,10 +716,21 @@ function wp_read_image_metadata( $file ) {
716716 * as caption, description etc.
717717 */
718718 if ( is_callable ( 'iptcparse ' ) ) {
719- @ getimagesize ( $ file , $ info );
719+ wp_getimagesize ( $ file , $ info );
720720
721721 if ( ! empty ( $ info ['APP13 ' ] ) ) {
722- $ iptc = @iptcparse ( $ info ['APP13 ' ] );
722+ if (
723+ // Skip when running unit tests.
724+ ! defined ( 'DIR_TESTDATA ' )
725+ &&
726+ // Process without silencing errors when in debug mode.
727+ defined ( 'WP_DEBUG ' ) && WP_DEBUG
728+ ) {
729+ $ iptc = iptcparse ( $ info ['APP13 ' ] );
730+ } else {
731+ // phpcs:ignore WordPress.PHP.NoSilencedErrors -- Silencing notice and warning is intentional. See https://core.trac.wordpress.org/ticket/42480
732+ $ iptc = @iptcparse ( $ info ['APP13 ' ] );
733+ }
723734
724735 // Headline, "A brief synopsis of the caption".
725736 if ( ! empty ( $ iptc ['2#105 ' ][0 ] ) ) {
@@ -779,7 +790,18 @@ function wp_read_image_metadata( $file ) {
779790 $ exif_image_types = apply_filters ( 'wp_read_image_metadata_types ' , array ( IMAGETYPE_JPEG , IMAGETYPE_TIFF_II , IMAGETYPE_TIFF_MM ) );
780791
781792 if ( is_callable ( 'exif_read_data ' ) && in_array ( $ image_type , $ exif_image_types , true ) ) {
782- $ exif = @exif_read_data ( $ file );
793+ if (
794+ // Skip when running unit tests.
795+ ! defined ( 'DIR_TESTDATA ' )
796+ &&
797+ // Process without silencing errors when in debug mode.
798+ defined ( 'WP_DEBUG ' ) && WP_DEBUG
799+ ) {
800+ $ exif = exif_read_data ( $ file );
801+ } else {
802+ // phpcs:ignore WordPress.PHP.NoSilencedErrors -- Silencing notice and warning is intentional. See https://core.trac.wordpress.org/ticket/42480
803+ $ exif = @exif_read_data ( $ file );
804+ }
783805
784806 if ( ! empty ( $ exif ['ImageDescription ' ] ) ) {
785807 mbstring_binary_safe_encoding ();
@@ -877,7 +899,7 @@ function wp_read_image_metadata( $file ) {
877899 * @return bool True if valid image, false if not valid image.
878900 */
879901function file_is_valid_image ( $ path ) {
880- $ size = @ getimagesize ( $ path );
902+ $ size = wp_getimagesize ( $ path );
881903 return ! empty ( $ size );
882904}
883905
@@ -892,7 +914,7 @@ function file_is_valid_image( $path ) {
892914function file_is_displayable_image ( $ path ) {
893915 $ displayable_image_types = array ( IMAGETYPE_GIF , IMAGETYPE_JPEG , IMAGETYPE_PNG , IMAGETYPE_BMP , IMAGETYPE_ICO );
894916
895- $ info = @ getimagesize ( $ path );
917+ $ info = wp_getimagesize ( $ path );
896918 if ( empty ( $ info ) ) {
897919 $ result = false ;
898920 } elseif ( ! in_array ( $ info [2 ], $ displayable_image_types , true ) ) {
0 commit comments