Initials Profile Pics

General plugins (Local) ::: local_ciabinitialsprofilepics
Maintained by Me, with my new 'slow explosion' hair!Paul Vaughan
A local plugin for Moodle which automatically creates profile pictures for users based on their initials.
Latest release:
205 sites
56 downloads
24 fans
Current versions available: 1
This plugin currently runs on PHP 7.0 as a minimum and will fail on lower versions.

Initials Profile Pictures generator

A local plugin for Moodle which automatically creates profile pictures for users based on their initials.

Written by Paul Vaughan (paulieboo@gmail.com@MoodleVaughany), © 2018.

Introduction

For our Moodle installation, we wanted unique profile pictures for each user instead of the generic default 'silhouette' image, without the requirement of each user uploading their own. This plugin automatically and silently creates a profile picture for each user from their initials when their profile is created or saved. A few classes were found which did roughly what we wanted, and they were used as inspiration for this plugin, as was the way the Android Contacts app displays people without images.

This plugin uses the Intervention Image library for PHP and was inspired by this wrapper for it.

Installation

Compatibility

This plugin has so far been tested with Moodle 3.2 and 3.4, but will probably work with all of the 3.x and most of the 2.x branches. It has a minimum requirement of PHP 7.0, however.

Requirements

  • PHP's GD image library.
  • PHP 7.0 or later.

This plugin uses the Intervention Image library for PHP (it and it's dependencies are included with the plugin; there is no need to use Composer) and was inspired by this wrapper for it, with a tip of the hat to the way default contact images are displayed in the Android Contacts app.

Installing

Install as you would any local Moodle plugin, by copying or cloning the ciabinitialsprofilepics folder into your Moodle's local/ folder. If you use git clone, please ensure the folder name is exactly as stated as it will not install or work otherwise.

Log in to your Moodle as an administrator and head to the Notifications page, where all being well, Moodle will discover the new plugin and install it.

There are an increasing number of configuration options, and I plan to make more of the plugin configurable over time.

How It Works

This plugin hooks in to Moodle's events system, so what whenever a user is created or their profile updated, if a profile picture wasn't included, it makes one from the user's initials and saves it to the user's profile. If you upload a profile picture yourself, that will of course be used, however if a profile image is deleted, this plugin kicks in and generates a new one.

Edit an existing user (or yourself)

  1. Go to your profile.
  2. Click Edit Profile.
  3. If you already have a profile picture, check the Delete box underneath it.
  4. Save your profile.

When the page reloads, you should see a new profile picture. The colour you get is dependant on your first initial, and is not random: it will not change if you recreate the image! (There are some settings you can change to enable random colours, or force a specific colour.)

If you have rights to edit other people's profiles, following the above steps for other users will generate a new profile picture for that user.

Creating new users

As new users are created, they will automatically get a profile picture created for them by default.

Configuration

Enabled: Check to enable; uncheck to disable. Note that this will not remove profile pictures created by this plugin.

Random Colour: Colours are usually chosen based on a user's first initial, so that if an image is removed and recreated, that user will get the same background colour. Check this option to choose a colour from the built-in palette utterly at random instead.

Force Colour: Pick a colour or type in a valid CSS hexadecimal colour code to force all images to use this colour.

Image Shape: Choose the shape of the generated image. There's quite a few to choose from. Note that some Moodle Themes may round the corners of images or make them appear circular (or other CSS trickery), despite the generated image not being that shape.

Font Size: Choose to have a big font which almost extends beyond the limit of the image, or a small font which is all clearly visible. Defaults to extra large (quite abstract).

Font Alpha: Choose the level of transparency, from 20% visible to 80% visible. (Defaults to just 20%.)

Note that some parts of the plugin without configuration settings can still be changed if you are happy to hack the locallib.php file. Most common settings are constants at the beginning of the file and have names like CIABINITIALSPROFILEPICS_BG_ALPHA.

To Do

Ideas I have had for future developments. If you want a feature added, raise an issue or send a pull request. smile

  • More shapes (some ideas, some implemented).
  • Multiple font choices, probably from a folder in the plugin, possibly using Google Fonts.
  • Editing of the built-in colour palette.
  • White or black text (multiple colours seems unnecessary...?).
  • Option to find all users without a profile picture and make them one.
    • Potentially do the above e.g. daily, via a scheduled task.
  • Option to remove all profile pictures and generate new ones.
  • Image generation exemptions for certain user types (such as admins) or users (whitelisted by ID).
  • Properly handle less (one) or more (up to four?) initials per image.

Bugs

I've noticed that the images this plugin generates are around 18-20kb, give or take, but when the image has been processed and saved into Moodle, the image's size jumps up to around 150kb. This seems a little odd and unnecessary!

Changelog

  • 2017-03-13: v1.0 Initial release.
  • 2017-03-14: v1.0.1 Use the correct font; update the current user's session with the new image.
  • 2017-03-14: v1.0.2 Missed a warning about duplicate admin pages - even though they work as intended.
  • 2017-04-01: v1.0.3 Refactored so that options and testing are easier to implement. Fixed a few minor bugs. Image size and scaling improved.
  • 2017-04-02: v1.0.4 Added font size and alpha-level settings (and corresponding tests).
  • 2017-04-05: v1.0.5 Replaced $str[0] with mb_substr($str, 0, 1) to better handle UTF8 characters. Unit tests.
  • 2017-04-07: v1.0.6 Shape selection option and more shapes.
  • 2017-05-10: v1.0.7 Fixes for some of the issues raised by moodle.org's plugin validation process.
  • 2017-06-06: v1.0.8 More fixes for some of the issues raised by moodle.org's plugin validation process, better testing, some minor bugs fixed.-*
  • 2018-03-26: v1.1 Purged all references to CiaB.
  • 2018-03-26: v1.1.1 Reverted most of the previous changes as the renaming of the whole plugin didn't play well with moodle.org.

Licence

This plugin is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This plugin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this plugin. If not, see www.gnu.org/licenses/.

Screenshots

Screenshot #0
Screenshot #1

Contributors

Me, with my new 'slow explosion' hair!
Paul Vaughan (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Kommentare anzeigen
  • Ricardo Caiado
    So., 18. März 2018, 04:36
    Hi,
    Any updates do Moodle 3.4?

    Ricardo
  • Me, with my new 'slow explosion' hair!
    Di., 27. März 2018, 07:08
    Hi Ricardo. This updated version should work fine on Moodle 3.4.
  • Dan Jeffries
    Fr., 6. Apr. 2018, 17:09
    Hi Paul

    Great plugin. Is there any way to 'force' everyone's profile to update, without them having to login, edit and save? With 100s of users, it would be nice to have a consistent look, and we can't rely on users to do this!

    Thanks.
  • Ricardo Caiado
    Fr., 6. Apr. 2018, 18:35
    Hi Paul,

    I´ve got the same situation as Dan. In my case I´ve got +26.000 users.

    Ricardo
  • Me, with my new 'slow explosion' hair!
    Mo., 16. Apr. 2018, 00:52
    Hi Dan, Ricardo. I've thought about that and it's on the to-do list. Give me a couple of days and I'll see what I can do!
  • Dan Jeffries
    Mi., 9. Mai 2018, 20:59
    Thanks Paul. Having this option to force everyone without an image will be a great leap forward!
  • Raymond Frangie
    Mo., 9. Juli 2018, 08:13
    Hi Paul - Will this work on 3.5?
    Cheers,
    Ray
  • Ricardo Caiado
    Mo., 30. Juli 2018, 18:53
    Hi,

    Any update to Moodle 3.5?

    Ricardo
  • Me, with my new 'slow explosion' hair!
    Mi., 16. Jan. 2019, 06:38
    This should work just fine in Moodle 3.5 and 3.6. I'm coming back to this plugin to add some features after a hiatus and initially, it works fine in 3.6, but more testing will happen soon as and when new features are added.
  • Muhammet Alkan
    Mo., 25. Feb. 2019, 20:41
    When i upload users by using a csv file (as an admin), this plugin does not work properly. It works properly when i just add a new user manually.
  • Edd Clementson
    Mo., 29. Apr. 2019, 16:31
    I can also confirm on version 3.6 that creating a new manual account works, whereas uploading users via a CSV file does not produce profile pictures/photos for the uploaded users traurig
  • Me, with my new 'slow explosion' hair!
    Mi., 23. Okt. 2019, 05:54
    There's a new version of this plugin addressing the 'users uploaded via CSV not getting a profile image created' issue.
  • Jey key
    Do., 24. Okt. 2019, 16:55
    Hello, plugin is great! I look into your to do list and i "need/want" exactly this one -> Multiple font choices, probably from a folder in the plugin, possibly using Google Fonts.
    For example i would like to have styled initials more like google (straight text, small text, space between firstname initial and lastname) lächelnd

    Anyway, thanks for plugin and gl in future with development!
  • Allen Williams
    Fr., 3. Apr. 2020, 11:00
    I am using Moodle 3.8 and the plugin works fine for users created manually. However, when I login as an Office365 user through by using Open ID Connect the initials show when I first enter the profile page and save. But it then disappears when using Moodle as that user and I need to go back to the profile each time for them to return. Any ideas?
  • Adrián G
    Fr., 5. Juni 2020, 18:18
    Hi,

    Any update to Moodle 3.8?
1 2
Please login to post comments