Display next image instead of fullsize popup Display next image instead of fullsize popup
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Display next image instead of fullsize popup

Started by roger484, March 14, 2008, 04:00:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

roger484

How do I modify my gallery so that when you click on an image it goes to the next image in the album, instead of displaying the full size image in a popup window?

Timos-Welt

#1
I'll explain how to solve this in detail. Open the theme.php of the theme that you use. Check if the following function is included:

function theme_html_picture()

If not, open theme.php from the sample theme and copy the whole function

function theme_html_picture()
{
....
}


to the theme you use, right before the ?> at the end of the file.

Now find this line in the function:

$pic_html = "<a href=\"javascript:;\" onclick=\"MM_openBrWindow('displayimage.php?pid=$pid&amp;fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=no,status=no,resizable=yes,width=$winsizeX,height=$winsizeY')\">";

This is the line that links to the Javascript that opens the full size window. If you e. g. want to avoid fullsize access in general, you could replace it by

$pic_html = "<a href=\"javascript:;\" >";

or if you want to send your users to Google everytime they click on a pic:

$pic_html = "<a href=\"http://www.google.com\" >";

(Doesn't make much sense, but I think you got the clue hehe)

But how to get the link to the next pic?

Again open the theme.php from the sample theme. Look for this function:

function theme_html_img_nav_menu()

As you can see, there's quite a bit of code in there; this portion looks promising:


    if ($pos < ($pic_count -1)) {
        $next = $pos + 1;
        $next_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$next$uid_link";
        $next_title = $lang_img_nav_bar['next_title'];
                                $meta_nav .= "<link rel=\"next\" href=\"$next_tgt\" title=\"$next_title\"/>
                                ";
    } else {
        $next_tgt = "javascript:;";
        $next_title = "";
    }


If we define the missing variables in our function theme_html_picture(), the code snip will work. The link then is in $next_tgt, so something like

$pic_html = "<a href=\"".$next_tgt."\" >";

should be ok. But we cannot simply paste the above code into the function theme_html_picture(), because the variables $pos, $pic_count, $cat, $cat_link and $uid_link are unknown there.

But we're lucky: $pos, $pic_count, $cat are global variables (have a look at the function theme_html_img_nav_menu, they're defined there in the first few lines very easily). All we need is to declare them global:


global $pos, $pic_count, $cat;


The next variables are defined in the function theme_html_img_nav_menu(), so we'll have a look for the corresponding lines there. Yes, they're in:


$cat_link = is_numeric($album) ? '' : '&amp;cat=' . $cat;
$uid_link = is_numeric($_GET['uid']) ? '&amp;uid=' . $_GET['uid'] : '';           


Now we have everything together: The code that generates the link, the variable definitions, and the line we have to exchange. So in the end, replace the line

$pic_html = "<a href=\"javascript:;\" onclick=\"MM_openBrWindow('displayimage.php?pid=$pid&amp;fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=no,status=no,resizable=yes,width=$winsizeX,height=$winsizeY')\">";

with


            global $pos, $pic_count, $cat;
            $cat_link = is_numeric($album) ? '' : '&amp;cat=' . $cat;
            $uid_link = is_numeric($_GET['uid']) ? '&amp;uid=' . $_GET['uid'] : '';           
            if ($pos < ($pic_count -1)) {
                  $next = $pos + 1;
                  $next_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$next$uid_link";
                  $meta_nav .= "<link rel=\"next\" href=\"$next_tgt\" title=\"$next_title\"/>
                                ";
             } else {
                  $next_tgt = "javascript:;";
                  $next_title = "";
             }
             $pic_html = "<a href=\"".$next_tgt."\" >";


and you're done.

Timos-Welt

I've edited my previous post, now the complete solution is in there.

Have fun,
Timo

my evil twin

Sorry for necromancing this thread,
but is it possible to jump to the thumbnail overview after the last image?

The solution now works, but after the last image, it jumps directly to the first again.
That's pretty confusing.

Thank you in advance.

my evil twin

Erm yeah, another question (not possible to edit posts here?):

how can i replace the "normal" imagelink (not fullsize) to act exactly the same?

now i have a few pictures, where the "next" link instead the fullsizelink works fine, but all those pictures without any fullsize version can't be clicked at to get to the next picture...

best wishes...

Αndré

Quote from: my evil twin on August 21, 2008, 12:34:33 PM
Sorry for necromancing this thread,
but is it possible to jump to the thumbnail overview after the last image?

The solution now works, but after the last image, it jumps directly to the first again.
That's pretty confusing.

Thank you in advance.
This is not related to the topic!

my evil twin

Yes it is!

Now, with this hack, after the last picture, the file description, numbering etc. won't change, BUT the picture will, and jump to the first one again.
so it's picture 45/45, text of picture 45, but showing the first one again.
that's confusing.

but anyway, i already did the necessary changes, works just fine.

best wishes.

Αndré

Quote from: my evil twin on August 21, 2008, 02:43:05 PM
i already did the necessary changes, works just fine.
Then say what you have done, so others can benefit from it.