• Resolved Shmoo

    (@macpresss)


    Just curious why does my filter not work?

    // Remove height/width attributes on avatar img tags.
    function myscript_remove_dimensions_avatars( $avatar ) {
    
        $avatar = preg_replace( '/(width|height)=\"\d*\"\s/', "", $avatar );
    
        return $avatar;
    
    }
    add_filter( 'get_avatar', 'myscript_remove_dimensions_avatars', 10 );
Viewing 2 replies - 1 through 2 (of 2 total)
  • Check, if this is working:

    $avatar = preg_replace(‘/(width|height)=\”\d*\”\s/’, “”, $avatar);
    $avatar = preg_replace(“/(width|height)=\’\d*\’\s/”, “”, $avatar);

    Found at:
    http://vanillaco.de/file.php?name=%2Fwp-user-avatar%2Ftags%2F1.8%2Fincludes%2Fwpua-functions.php#194-201

    Thread Starter Shmoo

    (@macpresss)

    That second option is working perfect, thank you so much I’ve been searching for this all day.

    @msoftware for president!

    Working code snippet, add this inside your functions.php file.

    // Remove height/width attributes on avatar img tags.
    function myscript_remove_dimensions_avatars( $avatar ) {
    
    	$avatar = preg_replace( "/(width|height)=\'\d*\'\s/", "", $avatar );
    
    	return $avatar;
    
    }
    add_filter( 'get_avatar', 'myscript_remove_dimensions_avatars', 10 );

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Trying to remove with and height attributes off get_avatar’ is closed to new replies.