Page 1 of 1

Insert user avatar images into comments

Posted: Mon Nov 07, 2011 2:19 am
by kgdd
I have a question:

Would it be possible to add a user image with each comment? For instance, if the admin started a new thread and commented on that thread as username Admin in the admin section, then the avatar code would display the admin.png image next to the comment. If anyone other than the admin commented on the post (not in the admin section), it would display a generic avatar image such as guest.png.

Also, how would I go about making the comment_user field unique? It wouldn't let me when I tried to set it as unique in phpmyadmin. I don't want users commenting to be able to put in Admin or any other already registered username..

Please let me know if this doesn't make sense, thanks in advance.

Re: Insert user avatar images into comments

Posted: Mon Nov 07, 2011 11:58 pm
by jacek
Well you could just check the name they enter against the list of registered users ? If it shows up on the list, show an error saying the name is taken already or something.

Re: Insert user avatar images into comments

Posted: Wed Nov 09, 2011 3:08 am
by kgdd
How about adding an image per comment based on the commentor?

Re: Insert user avatar images into comments

Posted: Wed Nov 09, 2011 3:56 pm
by Josh
In my opinion it sounds like you'd be better off making users register a unique username first.

Or if you want it so that people don't have to register you could have a "comments" table where each posts has their own unique id, then a "comments_avatars" or similar table which has the columns "comment_id" and "image_url". So when someone posts with an avatar the avatars url would be inserted into comments_avatars with the post id as "comment_id" then reference them from inside the display page. If the post doesn't have an avatar you could maybe display a default image or something.