getProfilePictureUrl([user]) Last updated: 16. May 2026
API only function
This function retrieves the URL of a user's profile picture from the system. It returns a string containing the direct link to the image, which can be used to display the user's profile picture in applications or web interfaces.
See also: writeJwt deleteJwt denyAccess logOut flagActivity Custom JWT login example
Parameters
| Name | Type | Description |
|---|---|---|
| user (optional) | string | If not specified, defaults to current user. |
Returns
Link to profile image, or null if not available.
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>