[Resolved] Avatar initials generation fails as size parameter is empty in url

    • February 19, 2026 at 1:33 am #25044

      When using the Initials avatar mode in osTicket Awesome theme, the avatar generation fails with a fatal error:

      Fatal error: Uncaught ValueError: imagecreatetruecolor(): Argument #1 ($width) must be greater than 0

      Root cause:

      The LocalAvatar::getUrl() method only adds the size parameter to the URL when $this->size is truthy. However, when getAvatar() is called without a size parameter (e.g., <?php echo $user->getAvatar(); ?> in templates), $this->size becomes an empty string “” rather than null.

      When the empty string is passed to the avatar URL, PHP’s (int) “” converts it to 0, which the GD library’s imagecreatetruecolor() cannot accept.

      Example problematic URL: avatar.php?uid=1&mode=initials&size=&name=Casper+

      We are running 1.8.3

    • March 3, 2026 at 8:33 am #25153
      stevland
      Keymaster

      Hi Carsten,

      Great catch, and thank you for the thorough diagnosis. You’ve nailed the root cause exactly: when getAvatar() is called without a size parameter, the empty string slips through to imagecreatetruecolor() as zero.

      This has been fixed in release 1.18.3-4, but if you’d rather not update right now, you can fix it in place by adding this line near the top of the render function in osta/php/avatar-initials.php, just before the image generation call:

      $size = max((int)$size, 80);

      Thanks for reporting this!

You must be logged in to reply to this topic.

Topic Tags