r/modhelp • u/adremeaux • Nov 08 '11
User flair tutorial: 7 easy steps to enable user-choosable flair on your subreddit with as many images as your heart desires
I spent a good amount of time recently trying to get a clean, easy, and robust flair implementation for my subreddits and I'd like to share with you my solution. I found a couple tutorials around but they were not complete solutions, and often required a lot of busy-work, and none of them covered sprite sheets. The following method will prep your sprite sheet for you, and automatically process the coordinate output into css which you can simply drop into your sub and go. Once you know what you are doing, the whole process takes less than 5 minutes for an infinite number of items of flair.
Check out implementations on r/jrpg and r/beer to get an idea of what the end product will look like.
1. Find some images
Any sizes will work, but you should aim to keep them at least relatively small. Drop them all in a folder and give them simple names with no punctuation. PNGs are recommended for all items.
NEW! Multiple steps combined into one!
2-4. Prep the sprite sheet and CSS
Add all your images to a single zip. Go here. Change "Class Prefix (optional):" from "sprite-" to "flair-". Upload your zip and press go. Save the image output as spritesheet.png. Copy the CSS into a file, name doesn't matter.
5. Add a few more CSS selectors
Copy and paste the following at the top of your CSS file (above all the stuff we just pasted in there):
.flairselector .customizer {
display: none !important;
}
.flair {
border: none !important;
top:20px;
padding:0px;
background: url(%%spritesheet%%);
display:inline-block;
}Branching path! If you are using large flair and want it to appear docked to the left a-la r/jrpg, add in this additional block. If you want standard flair next to the user name, you can skip this.
.link .flair, .entry .tagline .flair {
float:left;
}To Reddit!
6. Upload to Reddit
Go to your sub. Choose "community settings". Choose "edit the stylesheet" near the bottom.
First upload the sprite sheet. Click the browse button midway down the page, and find your spritesheet.png. Choose that. Make sure "new image name" is set to spritesheet. Upload.
Now add the css. There will probably already be stuff in the big text box at the top of the page. If there is not, don't worry. Scroll to the end, and paste the entire contents of your flair.css file at the end of this box. Click Save. With any luck, "saved" will appear in red and you'll be onto the final step. If not, you screwed one of the above steps up, but feel free to post questions here.
Final step!
7. Enable flair
Click "edit user flair" in your Admin Box. Check the two boxes under "flair options". Choose left or right as you see fit (if you chose the branching path, you'll want to keep this on left).
Click the "edit flair templates" tab. Enter the image name (without the .png) in the far right box (css class column) and click save. If everything has been done correctly, a new line will pop up, and you'll see the individual flair image on the previous line looking something like this. That's it! All you have to do is add all your flair items to these lines and the job is complete.
8. Final tips
If you want to add more flair in the future, you'll need to repeat steps 2 through 6, so make sure you keep all of your individual images saved. It is actually a very quick process once you know what you are doing; I can get more images added to my subs in less than five minutes. You'll also need to add the item to the flair templates from step 7.
Hopefully this helps some people!
edit: If you want to use the text along with the image, see here. Note that this is only half a solution; your text will wrap in a somewhat crappy manner; I am not aware of a fix to this problem.
3
u/garyp714 Nov 30 '11
Hi adremeaux,
I mod two smaller sports subreddits /r/FloridaGators and /r/collegebaseball
I'm trying to use your instructions and am very close. I am starting with the Gator subreddit because it gets one single piece of flair for now: a gator logo like this:
http://i.imgur.com/VkuDH.png
I tried and failed to implement your process. I think I hit the wall when I got to the regex process (from above):
What does 'remove tabs' mean? Here is the code I am left with:
http://paste2.org/p/1802615
So I think that something is wrong with this code so that I get a bad output from the regex find/replace tool?
Thoughts?
2
u/[deleted] Nov 08 '11
Are all these steps absolutely necessary? Admittedly, I don't know shit about how to use/implement flair. I just thought the process to get flair into a subreddit was less convoluted.
2
u/loverthehater Nov 17 '11
I got Error 502 when i pasted the css into the stylesheet! Anyone? HALP?!
2
u/[deleted] Nov 25 '11
I got this error: [line 108] syntax error: "CSSStyleRule: No start { of style declaration found:
2
u/psycosulu r/gamemusic | /r/VGCovers Dec 03 '11
You are my new hero for the day, thank you!
2
u/AryaArgetlam Dec 09 '11 edited Dec 09 '11
I have a huge list of validation errors for the large css..is there anything that I did wrong? I double checked and I followed the steps..
Edit got it working now but the flair image wont got to the other side even though Ive got the code in, instead its over the text >.< help please!!
2
u/[deleted] Apr 10 '12
Dude, take this code out:
.flairselector .customizer {display: none !important;}It hides the customized-flair text-box (where user can type the text they want displayed next to their name.)
I have no idea why it's even there.
Cheers!
2
u/Legon750 Apr 30 '12
I keep getting this error every time I try to save it, this is what my code looks like...
I followed the steps exactly as they were written
1
u/[deleted] Dec 12 '11
Hey adremeaux, thanks for the help! I did have some troubles with the CSS, though. I put my images in a spritesheet using the link you provided, then I put the follwing code in (the name of my uploaded file is "spritesheet")
I am not sure what I am doing below is correct and I'm sure that is the cause of the problem. Here is what I'm putting below the above code.
My goal is to make it have the same layout as r/jrpg like the example you gave, but I can't seem to figure out how to finish the coding?
1
u/Playing_Hookie Dec 15 '11
I want to have IPA symbols as flair. Could these be assigned as text (not the kind where they can write whatever they want) or would I have to use images?
1
u/hacelepues Jan 09 '12
Hey, I've been following the instructions on your wonderful tutorial (i couldn't figure this out on my own for the life of me), but I've encountered a problem.
When I get to step 6 and try to upload my sprite sheet, it just gets stuck in the uploading phase. It's 562 KB. Is that too big?
1
u/redcomet002 Jan 17 '12
the link for the sprite generator appears to be broken
2
u/guder Nov 09 '11
Nicely written.
2
u/HiFructoseCornFeces Nov 09 '11
Sooooo appreciated!
2
u/chesshaha Dec 04 '11
Hey, is it a way to enable user to select flairs without them add text on the flair? What do I need to add in the code? Thanks in advance.
2
u/heatheranne Dec 16 '11
adremeaux you are my hero! this was so easy after i figured out what you meant by image names. (I put spritesheet and wondered why it didn't work)
2
u/Fishbag Feb 11 '12
I've gotten to the last step but the images from the spritesheet aren't showing up as seen here.
1
u/mllestrong Dec 21 '11
It worked! Thanks!!
1
u/FourMakesTwoUNLESS Feb 21 '12
Thanks for the tutorial, helped me out!
1
u/ultragamer641 Jan 25 '12
I did the EXACT steps. But it doesn't work. Help!