How to determine what is the file name of avatar, while I have user ID available or avatar url.
I don't need url! I need exact file name in attachments folder or avatar directory if it is not uploaded. Second part is quite easy... but the first part is problem for me.
You can try doing some of these via loadMemberContext().
<?php// Grab SSI.php.require('SSI.php');// Easy-to-use function to get member data.function get_memberData($memID){ global $context, $memberContext; // Load the user's profile. loadMemberData($memID, false, 'profile'); loadMemberContext($memID); $context['member'] = $memberContext[$memID]; // Put the data into an array. foreach($context['member'] as $key => $value) $member[$key] = $value; // Return the data. return $member;}// Do we have a user id defined?$user_id = isset($_REQUEST['u']) ? (int) $_REQUEST['u'] : $context['user']['id'];// Put the data into ths variable.$memberData = get_memberData($user_id);// Read the data in the array.echo '<pre>';print_r($memberData);echo '</pre>';?>
In $memberData['avatar']['href'], you'll get the url yes, but it contains the folder that avatar is in. Unless you were looking to do it through php.
It's not solution for me. I can't have url - i must get direct, local path - like /home/forum/attachments/1_fc903404acc5f9af99e6d03d02e278839fa8de7b or /home/forum/avatars/somefoler/somefile.png
Well...if you know where your avatar directory is, you can do something like this.
<?php// dirname(__FILE__) assumes this file is in the root folder of your SMF Forum.$avatar_dir = dirname(__FILE__) . '/user_avatars/';$user_avatar = $avatar_dir . basename($memberData['avatar']['href']);?>
Well... not exactly.
$memberData['avatar']['href'] => http://www.informatyka.stgk.eu/index.php?action=dlattach;attach=135;type=avatar
So, it will give me only download link, while I really need direct filepath with real file name :)
Can you link me to the page with the code I provided?
http://www.informatyka.stgk.eu/av/
I use Imagick php extension - I don't know why code that was working, just stopped. I could use url by usinf fopen() and Imagick ReadImageFile method, but now it gives error - while using direct file name it doesn't. So that's why I can't use download link. Even /home/informatyka/www/attachments/index.php?action=dlattach;attach=135;type=avatar is not working.
That page doesn't look like the code i provided...
Also, I use SMF 2.0 RC1.2, and all my user's avatars have an image extension (via upload form in profile)
Quote from: tyty1234 on October 11, 2009, 07:36:26 PM
That page doesn't look like the code i provided...
Also, I use SMF 2.0 RC1.2, and all my user's avatars have an image extension (via upload form in profile)
I needed to change a little bit your code to make path correct, beacuse the file is not in root of forum.
Rest is based on what you wrote.
I als use SMF 2.0 RC1.2 And all my user's avatars don't have image extension, they are uploaded, and have links like attachments.
EDIT:
I figured it out - I need to make avatar folder, so avatars won't upload to attachments folder.
So rest is easy :)
Thanks.