get_wp_user_avatar generates a bad URL
-
When you use one of the named presets (ie; ‘thumbnail’) and the images filename ends in ‘avatar’, the URL generated winds up looking like “default-avatar-thumbnailx150.png”.
This happens on or around like 454, with the following:
// Remove width and height for non-numeric sizes
if(in_array($size, array(‘original’, ‘large’, ‘medium’, ‘thumbnail’))) {
$avatar = preg_replace(‘/(width|height)=\”\d*\”\s/’, “”, $avatar);
$avatar = preg_replace(“/(width|height)=\’\d*\’\s/”, “”, $avatar);
}
$replace = array(‘wp-user-avatar ‘, ‘wp-user-avatar-‘.$get_size.’ ‘, ‘wp-user-avatar-‘.$size.’ ‘, ‘avatar-‘.$get_size, ‘photo’);
$replacements = array(“”, “”, “”, ‘avatar-‘.$size, ‘wp-user-avatar wp-user-avatar-‘.$size.$alignclass.’ photo’);
$avatar = str_replace($replace, $replacements, $avatar);The problem is with the ‘avatar-‘.$get_size. Other filename collisions could also be a problem. The str_replace should probably be converted into a preg_replace that isolates the replacement to the class attribute (the intended target).
- The topic ‘get_wp_user_avatar generates a bad URL’ is closed to new replies.