Raised This Month: $32 Target: $400
 8% 

Player Avatars


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bongotrommler
Senior Member
Join Date: Feb 2013
Location: GG-Elite.Net
Old 01-21-2017 , 15:12   Player Avatars
Reply With Quote #1

Hi,

does anyone know how to get the Steam-Avatars via http @ pages/player_general.php?

thx

Last edited by bongotrommler; 01-24-2017 at 16:55.
bongotrommler is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 01-23-2017 , 01:23   Re: Player Avatars via https
Reply With Quote #2

Around line 97-108, you'll see:

Code:
                                                       $avimg = getImage("/avatars/$player");
                                                        if ($avimg)
                                                        {
                                                                $avatar_full = $avimg['url'];
                                                        }
                                                        else if ($avatar_full == '' || $playerdata['blockavatar'] == '1')
                                                        {
                                                                $avatar_full = IMAGE_PATH."/unknown.jpg";
                                                        }
                                                        if ($status == '')
                                                                $status = '(Unknown)';
                                                        echo("<img src=\"$avatar_full\" style=\"height:158px;width:158px;\" alt=\"Steam Community Avatar\" />");
Just before the echo, change $avatar_full to Steam's https URL:

Code:
                                                       $avimg = getImage("/avatars/$player");
                                                        if ($avimg)
                                                        {
                                                                $avatar_full = $avimg['url'];
                                                        }
                                                        else if ($avatar_full == '' || $playerdata['blockavatar'] == '1')
                                                        {
                                                                $avatar_full = IMAGE_PATH."/unknown.jpg";
                                                        }
                                                        if ($status == '')
                                                                $status = '(Unknown)';
                                                        $avatar_full = preg_replace("#(.+)/steamcommunity/public/images/avatars/(.+).jpg#", "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/$2.jpg", $avatar_full);
                                                        echo("<img src=\"$avatar_full\" style=\"height:158px;width:158px;\" alt=\"Steam Community Avatar\" />");
Steam has used multiple domain names, previously they were on "//media.steampowered.com", I mean to have seen them on "//cdn.akamai.steamstatic.com/" recently, but today they are on "//cdn.edgecast.steamstatic.com/".

With the above preg_replace, it is just changing the beginning of the URL, so any URL's will work given they match the Steam pattern.

This way "{ANYTHING_HERE}/steamcommunity/public/images/avatars/{ANYTHING_HERE}.jpg" will be adjusted to "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/{ANYTHING_HERE}.jpg".
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].

Last edited by DarkDeviL; 01-23-2017 at 01:27.
DarkDeviL is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:15.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode