getProfilePictureUrl([user]) Last updated: 17. Oct 2026

API only function

Returns the URL of a user's profile picture (a 164 × 164 thumbnail), for use in an img tag.

See also: writeJwt deleteJwt denyAccess logOut flagActivity Custom JWT login example

Parameters

Name Type Description
user (optional) string

Email of the user. Defaults to the logged-in visitor.

Returns

The URL of the profile picture. With a user given, the URL is built for that email without checking that the user exists. Without one, the logged-in visitor is used on a site with login; on a site without login the result is null.

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
// #/API/profile-picture.js — return the current user's profile picture URL
export default () => {

    if (!request.Jwt) {
        return docly.denyAccess();
    }

    return {
        url: docly.getProfilePictureUrl(request.Jwt.username)
    };
}

// On a hash page, fetch the URL and set the <img src> from JavaScript —
// never call docly.getProfilePictureUrl(request.Jwt.x) directly in a hash
// template, since the rendered output is cached and would leak the first
// user's picture to every other user.
//
//   <img id="avatar" alt="Profile">
//   <script>
//       fetch('/API/profile-picture')
//           .then(r => r.json())
//           .then(d => document.getElementById('avatar').src = d.url);
//   </script>