From e529b9d50f3b8c36701f2f1a2dc81b0a48162c44 Mon Sep 17 00:00:00 2001 From: yuriinalivaiko Date: Wed, 2 Apr 2025 22:23:14 +0300 Subject: [PATCH] - fixed PHP Warning that occurs when using the `getimagesize` function with an image from an external source. --- includes/core/um-actions-profile.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/includes/core/um-actions-profile.php b/includes/core/um-actions-profile.php index 101f5a21..520c42c2 100644 --- a/includes/core/um-actions-profile.php +++ b/includes/core/um-actions-profile.php @@ -737,18 +737,18 @@ function um_profile_dynamic_meta_desc() { $image_info = array(); $image_width = $image_size; $image_height = $image_size; - if ( false === strpos( $image, 'gravatar.com' ) ) { - // Ignore Gravatar image here and handler a real image. + $upload_dir = wp_get_upload_dir(); + if ( false !== strpos( $image, $upload_dir['url'] ) ) { + // Get the image size of the real image. $image = current( explode( '?', $image ) ); // strip $_GET attributes from photo URL. $image_path = wp_normalize_path( ABSPATH . wp_parse_url( $image, PHP_URL_PATH ) ); - $image_info = wp_check_filetype( $image_path ); - $imagesizes = getimagesize( $image_path ); - if ( is_array( $imagesizes ) ) { - list( $image_width, $image_height ) = $imagesizes; + if ( file_exists( $image_path ) ) { + $image_info = wp_check_filetype( $image_path ); + $imagesizes = @getimagesize( $image_path ); + if ( is_array( $imagesizes ) ) { + list( $image_width, $image_height ) = $imagesizes; + } } - } else { - // Gravatar image. - $image_path = esc_url_raw( $image ); } $person = array(