Get User Avatar File Name

@halilesen · 19 Apr 2024 · 377 views
Post Reply
User avatar
halilesen
#1 ·
Posts: 50
Joined: 24 Mar 2024, 18:09
Full Name: Halil ESEN
Has liked: 8
Been liked: 7
I was working on schema markup for the profile page, but it didn't seem possible by default to get the URL of the user's avatar photo. Because the {AVATAR_IMG} code that shows the avatar shows the avatar as <img> in page. But I only needed the avatar URL. After struggling for about an hour, I figured out how to do it. By sharing it here, I want to remember it for later and help those who need it.

Open /includes/functions_display.php file and find this line:

Code: Select all

'AVATAR_IMG'		=> phpbb_get_user_avatar($data),
Add this code after it:

Code: Select all

'AVATAR_IMG_SRC'    => $data['user_avatar'],
Save the changes. I can now get the name and type of the user's avatar image with code {AVATAR_IMG_SRC}. The output of this code is as follows for my current avatar.

2_1712756120.jpeg

Now when I want to create the user avatar url, I just need to write it like this:

Code: Select all

https://phpbbgroup.com/download/file.php?avatar={AVATAR_IMG_SRC}
Best.
Post Reply
  • Similar Topics