Hello Tech Guru. Welcome!
There are two workarounds for adding user handles in the alt attribute:
Method 1: Modify function qa_get_user_avatar_html() in qa-include/app/users.php and add the following line after line 675:
// Add user handle in 'alt' HTML attribute
$html = str_replace('" alt=""', '" alt="' . qa_html($handle) . '"', $html);
- Pros: Quick and easy way of getting the result you intended
- Cons: It'll get reverted to its initial form after updating Q2A
Method 2: Override function qa_get_user_avatar_html() via plugin.
function qa_get_user_avatar_html($flags, $email, $handle, $blobId, $width, $height, $size, $padding = false)
{
$html = qa_get_user_avatar_html_base($flags, $email, $handle, $blobId, $width, $height, $size, $padding);
// Add user handle in 'alt' HTML attribute
if ($html)
$html = str_replace('" alt=""', '" alt="' . qa_html($handle) . '"', $html);
return $html;
}
There's a great tutorial about how to create a plugin at https://docs.question2answer.org/plugins/tutorial/
- Pros: It'll work after Q2A updates
- Cons: None
This answer assumes you're willing to make it work by yourself, but I'll give you
a few suggestions just in case you find it difficult:
- Add a comment below, I (and other community members) can try to help you out.
- Find a developer friend and ask him to implement it for you.
- Get consultancy from one of the service providers or send me a private message.
Thank you for reading.