MU
3 ноября 2019 г. 16:20

Django letter avatar like this on evileg

python, Django, django

I try many apps and none of this create that nice letter avatars and cover on profile page. It's app or custom work?

It's possible to get a code? :)

2

Вам это нравится? Поделитесь в социальных сетях!

4
Evgenii Legotckoi
  • 3 ноября 2019 г. 23:31

Hello,

What you mean "letter avatar"? transliteration or email letter?

Avatars on this site are custom source code.

    MU
    • 4 ноября 2019 г. 2:34

    I mean this :)

    Avatar create from username. First letter. This is javascript, python? It's possible to get this somewhere, e.g github? :)

    I see evileg have code on github, but I don't see this in repository.

      Evgenii Legotckoi
      • 4 ноября 2019 г. 2:53
      • (ред.)

      In repository stable base functionality. It is open source core of site. But I move some functionality sometimes to open source.
      And I will send this functionality also. I think will move it in future ))

      But you can use this code for creating initials

      1. def first(value):
      2. try:
      3. return value[0]
      4. except IndexError:
      5. return ''
      6.  
      7. def initials(user):
      8. if user.get_full_name():
      9. return '{}{}'.format(first(user.first_name), first(user.last_name))
      10. return first(user.username)

      Position of letters in avatar is just html

        Evgenii Legotckoi
        • 4 ноября 2019 г. 2:56

        and this css

        1. .avatar-initials {
        2. display: flex;
        3. justify-content: center;
        4. align-items: center;
        5. color: #fff!important;
        6. text-decoration: none!important;
        7. font-weight: 700;
        8. font-size: 50%;
        9. }

          Комментарии

          Только авторизованные пользователи могут публиковать комментарии.
          Пожалуйста, авторизуйтесь или зарегистрируйтесь