mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-15 12:43:33 +09:00
Refactor profile image handling in Ultimate Member.
Simplified Gravatar image logic and improved code readability by restructuring the image processing flow. Removed redundant variable initialization and adjusted handling of `$image_info`. This ensures cleaner, more maintainable code while preserving existing functionality.
This commit is contained in:
@@ -734,29 +734,28 @@ function um_profile_dynamic_meta_desc() {
|
||||
$image = um_get_user_avatar_url( $user_id, 'original' );
|
||||
}
|
||||
|
||||
if ( FALSE === strpos( $image, 'gravatar.com' ) ) {
|
||||
// a real image.
|
||||
$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.
|
||||
$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 ) ) {
|
||||
$image_width = $imagesizes[0];
|
||||
$image_height = $imagesizes[1];
|
||||
list( $image_width, $image_height ) = $imagesizes;
|
||||
}
|
||||
} else {
|
||||
// the gravatar image.
|
||||
$image_path = esc_url_raw( $image );
|
||||
$image_info = array();
|
||||
$image_width = $image_size;
|
||||
$image_height = $image_size;
|
||||
// Gravatar image.
|
||||
$image_path = esc_url_raw( $image );
|
||||
}
|
||||
|
||||
$person = array(
|
||||
'@context' => 'https://schema.org',
|
||||
'@type' => 'ProfilePage',
|
||||
'dateCreated' => um_user( 'user_registered' ),
|
||||
'mainEntity' => array(
|
||||
'@context' => 'https://schema.org',
|
||||
'@type' => 'ProfilePage',
|
||||
'dateCreated' => um_user( 'user_registered' ),
|
||||
'mainEntity' => array(
|
||||
'@type' => 'Person',
|
||||
'name' => esc_attr( $title ),
|
||||
'alternateName' => um_user( 'user_login' ),
|
||||
@@ -767,6 +766,7 @@ function um_profile_dynamic_meta_desc() {
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$user_last_update = um_user( 'last_update' );
|
||||
if ( ! empty( $user_last_update ) ) {
|
||||
if ( is_numeric( $user_last_update ) ) {
|
||||
@@ -818,7 +818,7 @@ function um_profile_dynamic_meta_desc() {
|
||||
<?php if ( is_ssl() ) { ?>
|
||||
<meta property="og:image:secure_url" content="<?php echo esc_url( $image ); ?>"/>
|
||||
<?php } ?>
|
||||
<?php if ( $image_info && ! empty( $image_info['type'] ) ) { ?>
|
||||
<?php if ( ! empty( $image_info['type'] ) ) { ?>
|
||||
<meta property="og:image:type" content="<?php echo esc_attr( $image_info['type'] ); ?>" />
|
||||
<?php } ?>
|
||||
<meta property="og:url" content="<?php echo esc_url( $url ); ?>"/>
|
||||
|
||||
Reference in New Issue
Block a user