Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Display next image instead of fullsize popup  (Read 6338 times)

0 Members and 1 Guest are viewing this topic.

roger484

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Display next image instead of fullsize popup
« on: March 14, 2008, 04:00:43 pm »

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?
Logged

Timos-Welt

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 808
    • Timos-Welt
Re: Display next image instead of fullsize popup
« Reply #1 on: March 14, 2008, 04:50:49 pm »

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:

Code: [Select]
function theme_html_picture()
If not, open theme.php from the sample theme and copy the whole function

Code: [Select]
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:

Code: [Select]
$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

Code: [Select]
$pic_html = "<a href=\"javascript:;\" >";
or if you want to send your users to Google everytime they click on a pic:

Code: [Select]
$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:

Code: [Select]
function theme_html_img_nav_menu()
As you can see, there's quite a bit of code in there; this portion looks promising:

Code: [Select]
    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

Code: [Select]
$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:

Code: [Select]
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:

Code: [Select]
$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

Code: [Select]
$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

Code: [Select]
            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.
« Last Edit: March 14, 2008, 06:54:54 pm by Timos-Welt »
Logged

Timos-Welt

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 808
    • Timos-Welt
Re: Display next image instead of fullsize popup
« Reply #2 on: March 14, 2008, 06:56:28 pm »

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

Have fun,
Timo
Logged

my evil twin

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Re: Display next image instead of fullsize popup
« Reply #3 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.
Logged

my evil twin

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Re: Display next image instead of fullsize popup
« Reply #4 on: August 21, 2008, 12:52:49 pm »

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...
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Display next image instead of fullsize popup
« Reply #5 on: August 21, 2008, 02:31: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!
Logged

my evil twin

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Re: Display next image instead of fullsize popup
« Reply #6 on: August 21, 2008, 02:43:05 pm »

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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Display next image instead of fullsize popup
« Reply #7 on: August 21, 2008, 02:55:00 pm »

i already did the necessary changes, works just fine.
Then say what you have done, so others can benefit from it.
Logged
Pages: [1]   Go Up
 

Page created in 0.082 seconds with 20 queries.