2

I am using the Galleriffic jQuery plugin for my photo gallery. The gallery images are loaded from a database in PHP. I want to be able to link to one photo in the gallery from another web page, with an URL query that passes the ID of that image. This image should then be selected and shown in the big preview (or slideshow container), instead of the first image which is the default.

What I want to do is:

mywebsite.com/pictures/?pid=12345

where 12345 is the ID of the image to be selected.

ajgarn
  • 775
  • 7
  • 18

2 Answers2

6

or just do it in your client:

$(function(){
    var id = location.href.replace(/.*pid=/, '');
    $.galleriffic.gotoImage(id);
});

You can try to add id to the hash of the URL instead of query strings. e.g. URL would be:

http://mywebsite.com/pictures/#12345

add these code to your page:

$(function(){
    $.galleriffic.gotoImage(location.hash);
});

this would be better because Galleriffic doesn't change page URL when viewing different pictures.

alphakevin
  • 515
  • 3
  • 11
1

You can use some jQuery to click on a specific image after the gallery loads:

$("img#"+id).trigger('click');

There's a couple different way to populate the id variable. If you're using php as well you could use this:

<?php echo "var id = ".$_GET['pid'].";"; ?>
Jeremy
  • 437
  • 3
  • 16