What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 127 Stack Exchange communities.

What mechanism does stackoverflow.com flair use? Today i discovered that this website offers profile badges or flairs to the user to put up on the website. but the url that they provide if ending with .jpg extension. I guess how can a .jpg be always updated with my current profile reputations and how can it accept parameters like ?theme=clean

share|improve this question

migrated from stackoverflow.com Mar 22 '11 at 6:55

This question came from our site for professional and enthusiast programmers.

    
Shouldn't this be on meta? –  Bryan Ross Mar 22 '11 at 4:24
    
I guess this one is for meta.stackoverflow.com... –  EboMike Mar 22 '11 at 4:24
    
i am asking about the mechanism or technologies involved in such features of stackoverflow.com. not about the aesthetics of the features. so why should it be on the meta version? –  Coding-Freak Mar 22 '11 at 4:26
3  
The wording of the question should be changed. If you're asking how it is done, it should be asked here. If you are saying something is wrong with it (which there isn't) it should be on Meta. –  Jacob Mar 22 '11 at 4:27
2  
PLEASE DON"T TOUCH THIS, WHILE I FILE A BUG REPORT. –  Robert Harvey Mar 22 '11 at 4:35
    
what do you mean to say? @robert? –  Coding-Freak Mar 22 '11 at 4:38
1  
Look at the close votes. –  Robert Harvey Mar 22 '11 at 4:43
1  
Bug report is here: meta.stackexchange.com/questions/84169/… –  Robert Harvey Mar 22 '11 at 4:48
    
@Coding: You can't see the close votes. For some reason, there are 9 votes to close this question. Normally, 5 will automatically close (or migrate) the question. Something went wrong, hence Bob's authoritative voice. –  EboMike Mar 22 '11 at 4:48
1  
Should this question really be on Meta? –  alex Apr 11 '11 at 0:15
add comment

2 Answers

up vote 8 down vote accepted

Just because it has .jpg doesn't mean it points to a physical file.

Apache example

RewriteEngine on
RewriteRule ^users/flair/image.jpg$ generate-flair.php [PT]

PHP Example

// Generate flair
header('Content-Type: image/jpeg');
// Stream generated JPEG file

Update

your .htaccess example is okay to work with but, how do i put the part ^users/flair/image.jpg to ^users/flair/xxxxxxxxx.jpg, here xxxxxxxxx is the user_id

RewriteRule ^users/flair/(\d+).jpg$ generate-flair.php?id=$1 [PT]
share|improve this answer
    
your .htaccess example is okay to work with but, how do i put the part ^users/flair/image.jpg to ^users/flair/xxxxxxxxx.jpg, here xxxxxxxxx is the user_id. –  Coding-Freak Mar 22 '11 at 4:37
    
@Coding-Freak See update. –  alex Mar 22 '11 at 4:43
add comment

An extension in a URL doesn't really mean much.

You can redirect and process requests however you like.

Without knowing exactly how Stack Overflow have implemented it, I'd assume they redirect any requests to http://stackoverflow.com/users/flair/[number].png to a script that checks if it needs to recreate the image.

If nothing has changed since the last time it was generated, it would serve a cached image, if things have changed they would regenerate the image and serve it.

share|improve this answer
add comment

You must log in to answer this question.

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