Animated Avatar

:information_source: Summary Discourse Animated Avatars adds the ability for users to upload animated gif/webp avatars which will animate on hover or selection in posts, user cards, and profile pages.
:hammer_and_wrench: Repository Link https://github.com/discourse/discourse-animated-avatars
:open_book: Install Guide How to install plugins in Discourse

Features

By default, this pauses animation when not focused. Within topics, animation will pause when post is not hovered or selected.

animated_avatars_always_animate: overrides the above pausing, forces avatars to always animate.
animated_avatars_min_trust_level_to_display restrict animating of avatars by trust level.

Respects prefers-reduced-motion in the browser’s accessibility options: Animations will be disabled entirely.

Animated gifs are auto converted to webp on upload, reducing overall file size. This can be set with animated_gif_avatar_to_webp (default true).

Configuration

This plugin has an optional dependency on gifsicle. This is used to resize uploaded gif images to fit a square avatar, which helps to wrangle aspect ratios as well as normalize any differences between the static and animated images’ sizes for a smoother swap. The plugin will still function without it, but any non-square avatars may appear stretched when shown.

:information_source: gifsicle is not needed for animated_gif_avatar_to_webp. Animated gifs will be converted to webp with cropped square avatars.

To enable, you will add a call to the install script in your app.yml. A example of what the after_code hook will look like is the following:

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/discourse-animated-avatars.git
    - exec:
        cd: $home/plugins/discourse-animated-avatars
        raise_on_fail: false
        cmd:
          - $home/plugins/discourse-animated-avatars/scripts/install.sh

Settings

Name Description
animated avatars min trust level to display Min trust level to display an animated avatar
animated avatars always animate Always animate avatars
animated gif avatar to webp auto converts animated gif avatars to webp on upload, reducing file size. (default: true)
animated gif avatar webp quality the quality of the converted gif to webp. Recommended settings between 75% to 100% (default: 80%)

Technical

Additional CLI included to help with determining gif/webp avatar counts, and converting existing gif avatars to webp.

bin/rake animated_avatars:count_animated counts the total number of animated avatars, grouped by gif/webp

bin/rake animated_avatars:gif_to_webp converts existing animated gif avatars to webp. The new avatars are automatically applied, and existing gif avatars are removed by the CleanUpUploads job.

22 Likes