views:

28

answers:

1

Hi,

I'd like to track the views/impressions of images on web pages, but still allow the images to be embedded in HTML, like in the "img src="http://mysite.com/upload/myimage.jpg"/" element.

I know in Windows I can write a handler for ".jpg" so the URL will actually trigger a handling function instead of loading the images from disk. Is it possible to do that in python/django on Ubuntu server? Can web browser still cache the jpg files if it is not a straight file path?

It looks to me that this is how google picasaweb handles the image file name. I'd like to get some ideas on how to implement that.

Thanks!

-Yi

A: 

If you want images to not be cached, just append a timestamp to them. This example is in PHP, but you get the idea:

<img src=<?php echo '"../images/myimage.gif?'.time().'"'; /* Append time so image is not cached */ ?>

Then you can analyze your logs to track views, etc.

Justin Ethier
Hi, thanks for the response. I guess my question is, how to track the views of the photo if a static link I provided, like http://mysite.com/img/34adf.jpg, is embedded in HTML in a third-party web site (like blogs)? I can look at the log but it will be nice to be able to track using programs. Is that possible?
ycseattle