diff --git a/api/user_avatar.php b/api/user_avatar.php index 44daa36..a472a30 100644 --- a/api/user_avatar.php +++ b/api/user_avatar.php @@ -130,17 +130,8 @@ try { $entries = ldap_get_entries($ldap, $search); if ($entries['count'] > 0 && !empty($entries[0]['avatar'][0])) { - // lldap stores the avatar as a base64-encoded string in the LDAP attribute - $avatarRaw = $entries[0]['avatar'][0]; - // ldap_get_entries already decodes binary attributes; but lldap stores - // the avatar as a base64 string within the attribute value itself. - // Detect: if it starts with /9j/ (JPEG magic in base64) decode it. - if (substr($avatarRaw, 0, 4) === '/9j/') { - $avatarData = base64_decode($avatarRaw); - } else { - // Raw binary JPEG (starts with FF D8) - $avatarData = $avatarRaw; - } + // ldap_get_entries() returns the attribute value as raw binary. + $avatarData = $entries[0]['avatar'][0]; } ldap_unbind($ldap);