I'm sure this has been discussed and solved but I cannot seem to find a thread or node pertaining to it. Maybe I'm just searching for the wrong thing.
I'm trying to assign a default user picture/avatar for people who have not uploaded one yet.
My thinking is that I can check for whether or not the picture variable is empty, and if so, assign it a value which will call the default image url.
if (!isset($account[picture]))
unset($account[picture]);
$account[picture] = $account["none.jpg"];
I'm sure you'll be able to tell I'm a php novice, but I'm trying to get my hands dirty. The above code returns this error:
warning: Cannot use a scalar value as an array in blah blah blah
I understand the error, but am at a loss for how to fix it. My brother, who also works with drupal, told me he thought there was a built in default picture feature in one of the modules such as picture or profile or something else. I cannot seem to find one, but if anyone knows details of that, it would be much easier than coding it.
Any help with the feature or the code would be appreciated. Thanks in advance.
-Jesse
Comments
also...
I have also tried this:
This removes the error but is still not inputting the none.jpg into the code.
Now you can use
Now you can use http://drupal.org/project/imagecache_profiles
If I understand you
If I understand you correctly, you want a default picture on the user's profile page. Drupal does this under http://mysite.com/admin/settings/user. You may have to install the image module to do this.
--------------------->
underpressure
http://ravalonline.com
thanks...
Thanks, That fixed part of the problem actually. Now in my profile page the default avatar comes up in my guestbook snippet. However, the buddylist section still is not showing anything.
I am using somewhat hacked buddylist code to display the avatars, so I'm thinking that that may have something to do with it. I'm guessing now that I WILL have to code it to get the functionality I'm looking for. Any php gurus able to repair the code a few comments above this one?
anyone who cares...
I finally got it to work. Instead of inserting a value into the variable, I simply checked whether the variable was empty, and if so, printed an entire different sequence with the url to the default pic coded in. It takes a few more bytes, but who the hell cares?
This outputs a nice myspace like buddylist. It sorts from lowest uid to highest uid, not matter if you add them last or not. I'll be working on sorting soon. I also haven't tested the "more buddies" feature after I get to a certain amount of buddies.
Any takes on the code from php people would be appreciated as I am still learning.
are you saying your code
are you saying your code places an avatar / profile pic next to the uid in the buddy list?
--------------------->
underpressure
http://ravalonline.com
are you saying your code
are you saying your code places an avatar / profile pic next to the uid in the buddy list?
--------------------->
underpressure
http://ravalonline.com
yup
Actually, the way I have it styled, it places an avatar above the buddy name. I assume that if you changed the urls in the code it would work for other installations.