Author Topic: Avatars - Best method  (Read 559 times)

Offline Copy112

  • Level 5
  • *
  • Posts: 20
  • Reputation: +0/-0
    • View Profile
Avatars - Best method
« on: September 05, 2009, 04:52:09 AM »
Got some different ideas for how avatars can be added, but i'm not sure witch 1 is best.

Method 1.
Have a int in the user table, avatar = 1 or 0
If its 1, load the avatar from uploads/avatars/username or id.ext

Method 2.
Have a separate table, user_avatars or something, with a relation to user table.
Containing type, avatar. This would support loading external avatars to. Also generate a random value for the avatars file name.

Method 3.
Put a string with the same name as the generated number of the avatar into avatar in user table.

Method 4.
Detect if there is an avatar with the same id/username as the user and enable it. php file detection, no database involved.

Each method got benefits so im not sure witch 1 is the best.
« Last Edit: September 05, 2009, 04:53:43 AM by copy112 »

Offline Fizzadar

  • Level 8
  • *
  • Posts: 39
  • Reputation: +0/-0
  • Rawr!
    • View Profile
    • Fanatical Dev
Re: Avatars - Best method
« Reply #1 on: September 05, 2009, 10:53:41 AM »
Do you want anyone to be able to download them or not? If not, when they upload, save it as a random string with no extension, and use php to read it, you can also have .htaccess rewrite any access to the folder/stuff inside to just index. Just store the dataname in the users database.

Or, if you don't mind so much, just store it in the users database, or just use their ID, since that's not changing, it would work fine (I just use ID).
~Fizzadar

Offline Nox

  • Level 35
  • **
  • Posts: 767
  • Reputation: +12/-2
    • View Profile
Re: Avatars - Best method
« Reply #2 on: September 05, 2009, 12:29:57 PM »
Assuming I would use just uploaded avatars
I'd go for method #1 and use id... #2 is imho needlessly complicated, #3 is probably the same as #1 but a bit more space needed and I see no reason for it,
#4 is again demanding, you have to check the file on every load, which is worse than just include one more column into the query result

If external as well then probably #3
Meet us at an IRC irc.freenode.net #bbg as well
https://vimeo.com/36579366 (a must-watch) | Join BOINC - no longer a hype, but you can help never the less

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal