mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
Merge pull request #1147 from ultimatemember/feature/seo_image_size
Change the profile SEO image
This commit is contained in:
@@ -733,12 +733,73 @@ function um_profile_dynamic_meta_desc() {
|
||||
$description = um_convert_tags( UM()->options()->get( 'profile_desc' ) );
|
||||
$url = um_user_profile_url( $user_id );
|
||||
|
||||
$size = 190;
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_profile_dynamic_meta_image_size
|
||||
* @description Change the profile SEO image size. Default 190. Available 'original'.
|
||||
* @input_vars
|
||||
* [{"var":"$image_size","type":"int|string","desc":"Image size"},
|
||||
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.5.5"]
|
||||
* @usage add_filter( 'um_profile_dynamic_meta_image_size', 'function_name', 10, 2 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_profile_dynamic_meta_image_size', 'my_profile_meta_image_size', 10, 2 );
|
||||
* function my_profile_meta_image_size( $image_size, $user_id ) {
|
||||
* // your code here
|
||||
* return $image_size;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$image_size = apply_filters( 'um_profile_dynamic_meta_image_size', 190, $user_id );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_profile_dynamic_meta_image_type
|
||||
* @description Change the profile SEO image type. Default 'profile_photo'. Available 'cover_photo', 'profile_photo', .
|
||||
* @input_vars
|
||||
* [{"var":"$image_type","type":"string","desc":"Image type - cover_photo or profile_photo"},
|
||||
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.5.5"]
|
||||
* @usage add_filter( 'um_profile_dynamic_meta_image_type', 'function_name', 10, 2 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_profile_dynamic_meta_image_type', 'my_profile_meta_image_type', 10, 2 );
|
||||
* function my_profile_meta_image_type( $image_type, $user_id ) {
|
||||
* // your code here
|
||||
* return $image_type;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$image_type = apply_filters( 'um_profile_dynamic_meta_image_type', 'profile_photo', $user_id );
|
||||
|
||||
if ( 'cover_photo' === $image_type ) {
|
||||
if ( is_numeric( $image_size ) ) {
|
||||
$sizes = UM()->options()->get( 'cover_thumb_sizes' );
|
||||
if ( is_array( $sizes ) ) {
|
||||
$image_size = um_closest_num( $sizes, $image_size );
|
||||
}
|
||||
$image = um_get_cover_uri( um_profile( 'cover_photo' ), $image_size );
|
||||
} else {
|
||||
$image = um_get_cover_uri( um_profile( 'cover_photo' ), null );
|
||||
}
|
||||
} else {
|
||||
if ( is_numeric( $image_size ) ) {
|
||||
$sizes = UM()->options()->get( 'photo_thumb_sizes' );
|
||||
if ( is_array( $sizes ) ) {
|
||||
$size = um_closest_num( $sizes, $size );
|
||||
$image_size = um_closest_num( $sizes, $image_size );
|
||||
}
|
||||
$image = um_get_user_avatar_url( $user_id, $image_size );
|
||||
} else {
|
||||
$image = um_get_user_avatar_url( $user_id, 'original' );
|
||||
}
|
||||
}
|
||||
$image = um_get_user_avatar_url( $user_id, $size );
|
||||
|
||||
$person = array(
|
||||
"@context" => "http://schema.org",
|
||||
@@ -764,8 +825,10 @@ function um_profile_dynamic_meta_desc() {
|
||||
<meta property="og:description" content="<?php echo esc_attr( $description ); ?>"/>
|
||||
<meta property="og:image" content="<?php echo esc_url( $image ); ?>"/>
|
||||
<meta property="og:image:alt" content="<?php esc_attr_e( 'Profile photo', 'ultimate-member' ); ?>"/>
|
||||
<meta property="og:image:height" content="<?php echo (int) $size; ?>"/>
|
||||
<meta property="og:image:width" content="<?php echo (int) $size; ?>"/>
|
||||
<?php if ( is_numeric( $image_size ) ) { ?>
|
||||
<meta property="og:image:height" content="<?php echo absint( $image_size ); ?>"/>
|
||||
<meta property="og:image:width" content="<?php echo absint( $image_size ); ?>"/>
|
||||
<?php } ?>
|
||||
<meta property="og:url" content="<?php echo esc_url( $url ); ?>"/>
|
||||
|
||||
<meta name="twitter:card" content="summary"/>
|
||||
|
||||
Reference in New Issue
Block a user