Counting clicks on images.
July 2, 2008 - 8:09pm — rgnelson
| Project: | jQuery Lightbox Plugin (balupton edition) |
| Version: | 1.0.1-final |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | balupton |
| Status: | closed |
Jump to:
Description
I have a php script to update a mysql database by URL parameter.
ImageHits.php?pgf_id=
<?php
echo $row_rsGalleryImagesByID['pgf_id'];
?>How and where could I call the above page to count the clicks per large image.
Thank you for any help or point in the right direction.
RGNelson

Comments
#1
In the upcoming version you can do:
Add a name attribute like so:
<a rel="lightbox-tour" name="lightbox-image-22" href="sample/overview-large.jpg" title="Welcome to the jQuery Lightbox Plugin (balupton edition): This first set of images will go over some of the features with you.">Add the following script:
<script type="text/javascript">//<![CDATA[
$(function(){
$.Lightbox.handlers.show = function ( image )
{
// Prepare
var lookfor = 'lightbox-image-';
if ( image.name.indexOf(lookfor) === -1 )
{ // Doesn't have what we want
return null;
}
// Get the image id
var id = image.name.substring(lookfor.length);
// Do the request
$.get('ImageHits.php?pgf_id='+id);
}
});
//]]>
</script>
#2
#3
However, this will not log the hits if the lightbox was not used. You are best off using a php solution, so have the large image link to a php page (or a jpg with a .htaccess redirect to a php page), and then use the php page to serve up the image.
I've done up a script like this before for other work, and I could do it up and make it available for a fee.
#4
Thank you for the reply.
Is this now available in the july 10 release?
#5
That would be great!