My technician got it figured out. I think between the three of us he was able to come up with a final solution…
// Facebook OG Image Tags
add_filter( 'the_seo_framework_twitterimage_output', 'my_buddypress_profile_img' );
add_filter( 'the_seo_framework_ogimage_output', 'my_buddypress_profile_img' );
/**
* Adjusts after Featured Image URL for BuddyPress profile images.
*
* @staticvar string $iamge
*
* @return string $url The Escaped Avatar Image URL.
*/
function my_buddypress_profile_img( $image = '' ) {
static $image = null;
if ( isset( $image ) )
return $image;
if ( function_exists( 'bp_displayed_user_id' ) && $id = bp_displayed_user_id() ) {
/**
* We're on a profile page and we've found the displayed user ID. Fetch avatar URL.
* If no avatar is found, return empty string.
*/
$image = bp_core_fetch_avatar(array(
'item_id' => $id,
'type' => 'full',
'height' => 512,
'width' => 512,
'html' => false
));
}
return $image = esc_url( $image );
}
add_filter( 'the_seo_framework_twittercard_output', 'my_twittercard_adjustment' );
/**
* Adjusts Twitter Card type output when an image is found.
*
* @return string Twitter Card type
*/
function my_twittercard_adjustment( $type ) {
if ( my_buddypress_profile_img() ) {
//* Get default type from settings if image is found.
return tsf_get_option( 'twitter_card' );
} else {
//* Evaluate further.
return $type;
}
}
add_filter( 'the_seo_framework_ogtype_output', 'my_ogtype_adjustment' );
/**
* Adjusts OG Type output when an image is found.
*
* @return string OG type
*/
function my_ogtype_adjustment( $type ) {
if ( my_buddypress_profile_img() ) {
return 'profile';
} else {
// Evaluate further.
return $type;
}
}