80

Currently, you can get flair as HTML, Javascript, or JSON. Let's say I'm extra-cautious of XSS vulnerabilities. In that case the HTML and Javascript options are a no-no for me. JSON is possible if I use a trusted parser, but it's still just basically giving me HTML stored in a JS variable. A better option for me is a dynamically-generated image. You could cache the generated image for some time (say, 30 minutes?) to cut down on server demand.

Update: As pointed out by Kyle Cronin and rcar (see also meta.stackoverflow.com/questions/1238/…), a much greater need for this feature would be for use in sites which disallow iframes and scripting, for example when used as a sig on a forum, or when used on a blog hosted by wordpress.com.

Related: Offer additional properties to JSON flair

7
  • The only potential problem that I would bring up is the ability to "skin" the theme of the flair. However, if that can be overcome somehow, this might work nicely. Jul 1, 2009 at 14:27
  • 1
    the desired "skin" could still be passed in via query string, like parameters for size of a gravatar image
    – Kip
    Jul 1, 2009 at 14:38
  • 3
    What does status-deferred mean? It's not declined, nor accepted. Is it in limbo somewhere? Jul 12, 2009 at 0:13
  • 3
    defer : postpone, hold back to a later time Sep 20, 2009 at 8:06
  • Related: Flair as Images: ASP MVC Style Feb 3, 2010 at 19:57
  • @Somnath: see this blog post (linked to from the now-top-voted answer - sorry Steven!)
    – Shog9
    Mar 12, 2012 at 0:55
  • 1
    Yes, we have that now, but not without the cookie! May 24, 2018 at 13:47

5 Answers 5

28

Now possible:

http://SITE.stackexchange.com/users/flair/YOUR-USER-ID.png  

More details in the blog. Note that the network flair only shows accounts that have > 200 rep.

1
5

Just to add to this, it would also allow the image to still work when SO is down for maintenance because the server serving the images could be entirely separate (and lightweight). I'd really like to see this too.

3
  • It would also reduce the need to have a time based image cache strategy. Jul 1, 2009 at 15:24
  • @brad: i think the time-based cache would still be a good idea... the code to generate an image (including fetching the gravatar image) is going to be several orders of magnitude slower than just reading a cached image. imagine if i include my flair image on a super popular site, then SO would have to generate the image millions of times at once. of course, maybe the overhead is low enough that this is still feasible... i'm just saying if i were designing it i'd use a time-based cache (and i was trying to head off potential excuses not to do this)
    – Kip
    Jul 1, 2009 at 15:45
  • Image based flair shouldn't need to be cached less 64 hours. Seriously though, who needs his flair to be updated more than once a day or so? That would be very lightweight on the server.
    – perbert
    Jul 12, 2009 at 3:56
4

Image Based Flair

I have created an implementation of flair which generates an image of your current reputation automatically. It is currently using PHP GD.

More Information


Current Features

Configurable
Edit your accounts by opening system/config.yaml and editing the values.

Customizable
Create your own themes by editing/adding YAML files. (2 themes by default [basic,advanced] in 2 different flavors [normal, inverted])

Expandable
Currently supports all 4 SO sites. Adapts to new additions to the StackOverflow family with a simple config file.


Examples

This script no longer works due to the new flair API. I have no intention of updating it.

The desktop theme included in the distribution will not render exactly the same as the above. The reason is that I didn't include one font used due to licensing restrictions. For reference, the reputation font (missing) is DIN 1451 Engschrift LT. The theme files are as in, so by dropping in the font as dinb.ttf in the system/fonts folder, it should render as the above.

2
3

Have you tried StackImage?

It does exactly that.

http://stackimage.quickmediasolutions.com/flair.php?id=142114&site=meta http://stackimage.quickmediasolutions.com/flair.php?id=142114&site=meta&border=ffffff&background=3b5998&text=ffffff&title=dddddd&font1=serif&font2=serifitalic

It is highly customizable and also has smart caching to prevent excessive load on my server.

0

It would also be nice to be able to retrieve flair data as XML. It would make it easier to customize the way it's displayed, using XSL for instance.

4
  • unlikely, since JSON is so much more web-friendly Aug 23, 2009 at 3:46
  • Yes, but it's not as easy as XML to read from C#... come on Jeff, it can't take you more that 10 minutes ;) Aug 23, 2009 at 20:34
  • Two comments: @Jeff, wake up but not the whole world is web (or even web-friendly). @Thomas, wasn't there a JSON reader/writer in the .NET framework already?
    – peSHIr
    Oct 6, 2009 at 6:54
  • @peSHIr: yes, I think there is... but I like XML, and anyway I don't like the idea of using a Javascript format in C# ;) Oct 25, 2009 at 0:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .