Using Custom User Avatars¶
What the customer sees¶
When a customer is logged in and opens an account page (any address starting with /account), a box titled Profile picture is added to the page. It shows:
- the current picture (the uploaded avatar, or the Paymenter default if none was uploaded),
- the hint "PNG, JPG, or WebP - max 2 MB",
- a file field and an Upload button.
The box is inserted with JavaScript after the page loads. On the account page it is placed below the card that contains the e-mail field. If no such card is found, it is placed after a section whose heading contains "personal", and otherwise after the first element of the main content area.
Uploading a picture¶
- The customer opens their account page.
- They choose an image in the Profile picture box.
- They click Upload.
The page reloads and the new picture is shown. Uploading again replaces the previous picture: the old file is deleted and the new one is saved.
The upload is rejected if no file is chosen, if the file is not an image or if it is larger than 2 MB. In that case the customer is sent back to the page and the picture stays unchanged.
Note
There is no button to remove an avatar. A customer can only replace it with another picture.
Where the avatar appears¶
On every client-area page, the extension swaps the avatar images for the uploaded picture in the customer's browser. With Paymenter's default theme this covers the avatar images in the navigation.
Images are matched by these rules:
- images inside
header,navor.navbarwhose alt text contains "avatar" or "profile", or that have adata-avatarattribute, - any image on the page whose CSS class contains "avatar" or "profile".
The avatar is not used in these places:
- the admin area (addresses starting with
/admin), - pages seen by other users or by staff: a customer's uploaded picture is only shown to that customer,
- e-mails.
Automatic behaviour¶
- The picture address carries a version number based on the file's modification time, so browsers load a new upload without a cache clear.
- The swap runs again after each in-page navigation in the client area.
- If the saved file is missing from the disk, the customer sees the default avatar again.
- The extension has no cron job and sends no e-mails.