jquery-php magic:如何从主页循环fancybox中打开帖子页面

I run a custom fancybox within wordpress; the homepage loop is a grid of "featured images"; clicking on them doesn't open a post page but rather a fancybox with the image from the post (usually there's only one).

This is done by replacing the_permalink with a php function that fetches the direct url of the (first) picture in the post. So far so good.

Now the picture has opened in fancybox; Here I've already added a beautifully working "print" link; what I need next to it, is a link to the actual post page I took that image from!!

this is too hard for me brains...

... how to inform Fancybox of such variable??

Obviously, telling fancybox to use <?php get_the_permalink(); ?> won't work (the php snippet will be converted to url characters; besides, would it know the postID? I doubt it);

I tried different variants of ajax I found on this website to similar purposes but I couldn't get any of them to work. I don't think I am on the right track.

What's the method? The moment the user clicks on the fancybox link on the home page, the image url should be sent into the fancybox script together with (for example) the post ID or the post permalink, to allow fancybox to use such variables to generate the link.

At that point a simple window.location.replace(permalink); bound to a click action would work. But my brain cannot see how can I pass that permalink or id to fancybox. :(

Sorry for the lack of code, I'll post anything you think can help.

(n.b.: I'm using fancybox 1.3.7; it is customized only insofar it has a print button and little similar changes, no big deal)

sorry for answering my own answer -- I am new to this :) Anyway here it is ...by writing the above post, I actually helped my brain to figure a solution to this, which is rather straightforward:

fancybox uses a lot of variables, not just the href; I will use one of them to carry the permalink through, for example title, or even add a new variable (adding a custom variable would happen at the top of the fancybox script, where this is done:

_start = function() {
        var obj = selectedArray[ selectedIndex ],
            href, 
            type, 
            title,
            str,
            emb,
            ret;

        _abort();

but I'm not trying to do this now).

so I would have such situation, on the php side:

<a class="fancybox-image" title="<?php echo get_the_permalink(); ?>"    href="<?php echo just_the_image(); ?>">

(the function just_the_image is taking the first image of the post as mentioned above)

then on the jquery side, inside the fancybox script, I'll do this (hope this will answer Erik request as well):

outer.append(permabox = $('<div id="#permabox"></div>'));

and a few lines down, I bind this action to the "permabox" thingy:

$('#permabox').bind("click", function(){
var mytitle = $('#fancybox-title-over').prop('innerHTML');
window.location.replace(mytitle);});

(notice that to get the title as a string, I used the innerHTML of fancybox; not the most straightforward way I reckon);

the above is not the best solution, since fancybox is in the habit of displaying the title under the image; adding a custom variable to this purpose, as suggested above, would be better -- but the point is, the above works :)