WordPress.org

Ready to get started?Download WordPress

Forums

Simple Local Avatars
Avatar file name should not be based on display name (5 posts)

  1. Ov3rfly
    Member
    Posted 1 year ago #

    Avatar file name should not be based on display name but on username.

    If the display name contains german umlauts like äöü or other "weird" utf-8 chars, it will end up as a filename like "Türk_avatar.jpg" if the display name is "Türk".

    Note that the currently used sanitize_file_name() does not handle these cases, maybe give sanitize_title() a try if you can't use the username.

    Filenames like the above cause many problems when being backed up / restored by a plugin or if the wordpress site is copied to a different operating system or server, like linux to windows or similar.

    Workaround for current version 1.3.1:

    1. Select the username as display name in user profile (and check delete avatar checkbox if an avatar was saved before)
    2. Update user profile
    3. Select the avatar file
    4. Update user profile
    5. Switch back to your desired display name
    6. Update user profile

    Then the avatar file name will be based on username.

    http://wordpress.org/extend/plugins/simple-local-avatars/

  2. SomniumLucidus
    Member
    Posted 1 year ago #

    Ov3rfly, you da man. Replacing sanitize_file_name() with sanitize_title() fixes the problem with the accents, umlauts and other “non-standard” characters in names. Thanks!

  3. marchalyoan
    Member
    Posted 1 year ago #

    if you replace sanitize_file_name() with sanitize_title() the request don't finish properly

  4. Ov3rfly
    Member
    Posted 1 year ago #

    Which request exactly? What is "not properly" in your understanding?

    Please post your changed code as well, thanks.

  5. Ov3rfly
    Member
    Posted 10 months ago #

    This problem is still in 2.0 and WordPress 3.5.2.

    If a user display name is Max Möstermann, the filename becomes wrong encoded Max-Möstermann_avatar_1371927978.jpg and e.g. on a windows-server WordPress then tries to get the image file as Max-Möstermann_avatar_1371927978.jpg which is not found, so the avatar is broken.

    Filenames like the above also cause many problems when being backed up / restored by a plugin or if the wordpress site is copied to a different operating system or server, like linux to windows or similar.

    Quickfix for 2.0, known side-effect: filename is forced to lowercase.

    Old, simple-local-avatars.php, line 489

    $name = $base_name = sanitize_file_name( $user->display_name . '_avatar_' . time() );

    New, simple-local-avatars.php, line 489

    $name = $base_name = sanitize_title( $user->display_name . '_avatar_' . time() );

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic