Advanced search  

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

Pages: [1]   Go Down

Author Topic: random images on full image view  (Read 9991 times)

0 Members and 1 Guest are viewing this topic.

mahesh1825

  • Coppermine newbie
  • Offline Offline
  • Posts: 12
random images on full image view
« on: January 21, 2011, 04:09:06 pm »

Hi Sir

How can i place random images(clickable thumbnails) (for a defined number max 5 to 6) on full image view page.

some kind of noob here please give me detailed view.

http://localhost/displayimage.php?album=1&pid=3#top_display_media

Iam working on 1.5.12 version.

thanks in advance
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: random images on full image view
« Reply #1 on: January 21, 2011, 04:32:49 pm »

Open themes/yourtheme/theme.php and copy the following code right before the
Code: [Select]
?>
Code: [Select]
function theme_display_fullsize_pic()
{
    global $CONFIG, $THEME_DIR, $FORBIDDEN_SET, $LINEBREAK, $pid;
    global $lang_errors, $lang_fullsize_popup, $lang_charset;

    $superCage = Inspekt::makeSuperCage();

    if (!USER_ID && $CONFIG['allow_unlogged_access'] <= 2) {
        printf($lang_errors['login_needed'],'','','','');
        die();
    } elseif (USER_ID && USER_ACCESS_LEVEL <= 2) {
        printf($lang_errors['access_intermediate_only'],'','','','');
        die();
    }
    if ($superCage->get->keyExists('picfile')) {
        if (!GALLERY_ADMIN_MODE) {
            cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
        }
        //$picfile = $_GET['picfile'];
        //$picfile = $superCage->get->getPath('picfile'); // doesn't work with HTML entities
        $matches = $superCage->get->getMatched('picfile', '/^[0-9A-Za-z\/_.-]+$/');
        $picfile = $matches[0];
        $picname = $CONFIG['fullpath'] . $picfile;
        $imagesize = @getimagesize($picname);
        $imagedata = array('name' => $picfile, 'path' => path2url($picname), 'geometry' => $imagesize[3]);
    } elseif ($pid) {
        $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight FROM {$CONFIG['TABLE_PICTURES']} AS p " . "WHERE pid='$pid' $FORBIDDEN_SET";
        $result = cpg_db_query($sql);
        if (!mysql_num_rows($result)) {
            cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
        }
        $row = mysql_fetch_assoc($result);
        $pic_url = get_pic_url($row, 'fullsize');
        $geom = 'width="' . $row['pwidth'] . '" height="' . $row['pheight'] . '"';
        $imagedata = array('name' => $row['filename'], 'path' => $pic_url, 'geometry' => $geom);
    }
    if ((!USER_ID && $CONFIG['allow_unlogged_access'] <= 2) || (USER_ID && USER_ACCESS_LEVEL <= 2)) {
        // adjust the size of the window if we don't have to catter for a full-size pop-up, but only a text message
        $row['pwidth'] = 200;
        $row['pheight'] = 100;
    }

    $charset = ($CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset']);
    $fullsize_html = <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=$charset" />
        <title>{$CONFIG['gallery_name']}: {$lang_fullsize_popup['click_to_close']}</title>
        <style type="text/css">
            body { margin: 0; padding: 0; background-color: gray; }
            img { margin:0; padding:0; border:0; }
            #content { margin:0 auto; padding:0; border:0; }
            table { border:0; width:{$row['pwidth']}px; height:{$row['pheight']}px; border-collapse:collapse}
            td { vertical-align: middle; text-align:center; }
        </style>

        <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
        <script type="text/javascript" src="js/jquery.dimensions.pack.js"></script>
        <script type="text/javascript" src="js/displayimage.fullsize.js"></script>
    </head>
    <body style="margin:0px; padding:0px; background-color: gray;">

EOT;
    if ($CONFIG['transparent_overlay'] == 1) {
        $fullsize_html .= <<<EOT
        <table cellpadding="0" cellspacing="0" align="center" style="padding:0px;">
            <tr>

EOT;
        $fullsize_html .=  '<td align="center" valign="middle" background="' . htmlspecialchars($imagedata['path']) . '" ' . $imagedata['geometry'] . ' class="image">';
        $fullsize_html .=  '<div id="content">';
        $fullsize_html .=  '<a href="javascript: window.close()" style="border:none"><img src="images/image.gif?id='
                . floor(rand()*1000+rand())
                . '&amp;fullsize=yes" '
                . $imagedata['geometry']
                . ' alt="'
                . htmlspecialchars($imagedata['name'])
                . '" title="'
                . htmlspecialchars($imagedata['name'])
                . $LINEBREAK . $lang_fullsize_popup['click_to_close']
                . '" /></a><br />' . $LINEBREAK;
        $fullsize_html .=  <<<EOT
                    </div>
                </td>
            </tr>
        </table>

EOT;
    } else {
        $fullsize_html .=  '        <div id="content">'.$LINEBREAK;
        $fullsize_html .=  '<a href="javascript: window.close()"><img src="'
        . htmlspecialchars($imagedata['path']) . '" '
        . $imagedata['geometry']
        . 'id="fullsize_image" alt="'
        . htmlspecialchars($imagedata['name'])
        . '" title="'
        . htmlspecialchars($imagedata['name'])
        . $LINEBREAK . $lang_fullsize_popup['click_to_close']
        . '" /></a><br />' . $LINEBREAK
        . '        </div>'.$LINEBREAK;
    }
    ob_start();
    display_thumbnails('random', 0, 1, $CONFIG['thumbcols'], 1, false);
    $random_pics = ob_get_clean();
    $fullsize_html .= $random_pics;
    $fullsize_html .= <<<EOT
  </body>
</html>

EOT;

    $fullsize_html = CPGPluginAPI::filter('fullsize_html', $fullsize_html);
    echo $fullsize_html;
}

This probably doesn't look as you want, so you have to adjust that part:
Code: [Select]
    ob_start();
    display_thumbnails('random', 0, 1, $CONFIG['thumbcols'], 1, false);
    $random_pics = ob_get_clean();
    $fullsize_html .= $random_pics;
Logged

mahesh1825

  • Coppermine newbie
  • Offline Offline
  • Posts: 12
Re: random images on full image view
« Reply #2 on: January 21, 2011, 04:52:09 pm »

little bit deformed page. but i need to place it on the top of the page. if you dont mind can give me the idea. to place random thumbnails on the top of the page.

your give code gives me the thumbnails at bottom part.

Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: random images on full image view
« Reply #3 on: January 21, 2011, 05:01:52 pm »

Use this code:
Code: [Select]
function theme_display_fullsize_pic()
{
    global $CONFIG, $THEME_DIR, $FORBIDDEN_SET, $LINEBREAK, $pid;
    global $lang_errors, $lang_fullsize_popup, $lang_charset;

    $superCage = Inspekt::makeSuperCage();

    if (!USER_ID && $CONFIG['allow_unlogged_access'] <= 2) {
        printf($lang_errors['login_needed'],'','','','');
        die();
    } elseif (USER_ID && USER_ACCESS_LEVEL <= 2) {
        printf($lang_errors['access_intermediate_only'],'','','','');
        die();
    }
    if ($superCage->get->keyExists('picfile')) {
        if (!GALLERY_ADMIN_MODE) {
            cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
        }
        //$picfile = $_GET['picfile'];
        //$picfile = $superCage->get->getPath('picfile'); // doesn't work with HTML entities
        $matches = $superCage->get->getMatched('picfile', '/^[0-9A-Za-z\/_.-]+$/');
        $picfile = $matches[0];
        $picname = $CONFIG['fullpath'] . $picfile;
        $imagesize = @getimagesize($picname);
        $imagedata = array('name' => $picfile, 'path' => path2url($picname), 'geometry' => $imagesize[3]);
    } elseif ($pid) {
        $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight FROM {$CONFIG['TABLE_PICTURES']} AS p " . "WHERE pid='$pid' $FORBIDDEN_SET";
        $result = cpg_db_query($sql);
        if (!mysql_num_rows($result)) {
            cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
        }
        $row = mysql_fetch_assoc($result);
        $pic_url = get_pic_url($row, 'fullsize');
        $geom = 'width="' . $row['pwidth'] . '" height="' . $row['pheight'] . '"';
        $imagedata = array('name' => $row['filename'], 'path' => $pic_url, 'geometry' => $geom);
    }
    if ((!USER_ID && $CONFIG['allow_unlogged_access'] <= 2) || (USER_ID && USER_ACCESS_LEVEL <= 2)) {
        // adjust the size of the window if we don't have to catter for a full-size pop-up, but only a text message
        $row['pwidth'] = 200;
        $row['pheight'] = 100;
    }

    $charset = ($CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset']);
    $fullsize_html = <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=$charset" />
        <title>{$CONFIG['gallery_name']}: {$lang_fullsize_popup['click_to_close']}</title>
        <style type="text/css">
            body { margin: 0; padding: 0; background-color: gray; }
            img { margin:0; padding:0; border:0; }
            #content { margin:0 auto; padding:0; border:0; }
            table { border:0; width:{$row['pwidth']}px; height:{$row['pheight']}px; border-collapse:collapse}
            td { vertical-align: middle; text-align:center; }
        </style>

        <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
        <script type="text/javascript" src="js/jquery.dimensions.pack.js"></script>
        <script type="text/javascript" src="js/displayimage.fullsize.js"></script>
    </head>
    <body style="margin:0px; padding:0px; background-color: gray;">

EOT;
    ob_start();
    display_thumbnails('random', 0, 1, $CONFIG['thumbcols'], 1, false);
    $random_pics = ob_get_clean();
    $fullsize_html .= $random_pics;
    if ($CONFIG['transparent_overlay'] == 1) {
        $fullsize_html .= <<<EOT
        <table cellpadding="0" cellspacing="0" align="center" style="padding:0px;">
            <tr>

EOT;
        $fullsize_html .=  '<td align="center" valign="middle" background="' . htmlspecialchars($imagedata['path']) . '" ' . $imagedata['geometry'] . ' class="image">';
        $fullsize_html .=  '<div id="content">';
        $fullsize_html .=  '<a href="javascript: window.close()" style="border:none"><img src="images/image.gif?id='
                . floor(rand()*1000+rand())
                . '&amp;fullsize=yes" '
                . $imagedata['geometry']
                . ' alt="'
                . htmlspecialchars($imagedata['name'])
                . '" title="'
                . htmlspecialchars($imagedata['name'])
                . $LINEBREAK . $lang_fullsize_popup['click_to_close']
                . '" /></a><br />' . $LINEBREAK;
        $fullsize_html .=  <<<EOT
                    </div>
                </td>
            </tr>
        </table>

EOT;
    } else {
        $fullsize_html .=  '        <div id="content">'.$LINEBREAK;
        $fullsize_html .=  '<a href="javascript: window.close()"><img src="'
        . htmlspecialchars($imagedata['path']) . '" '
        . $imagedata['geometry']
        . 'id="fullsize_image" alt="'
        . htmlspecialchars($imagedata['name'])
        . '" title="'
        . htmlspecialchars($imagedata['name'])
        . $LINEBREAK . $lang_fullsize_popup['click_to_close']
        . '" /></a><br />' . $LINEBREAK
        . '        </div>'.$LINEBREAK;
    }
    $fullsize_html .= <<<EOT
  </body>
</html>

EOT;

    $fullsize_html = CPGPluginAPI::filter('fullsize_html', $fullsize_html);
    echo $fullsize_html;
}

little bit deformed page
Yes, that's why I said:
This probably doesn't look as you want, so you have to adjust that part:
Code: [Select]
    ob_start();
    display_thumbnails('random', 0, 1, $CONFIG['thumbcols'], 1, false);
    $random_pics = ob_get_clean();
    $fullsize_html .= $random_pics;
as it's just a quick & dirty mod.
Logged

mahesh1825

  • Coppermine newbie
  • Offline Offline
  • Posts: 12
Re: random images on full image view
« Reply #4 on: January 22, 2011, 05:53:35 am »

I can't able to fix it. by editing.
Code: [Select]
ob_start();
    display_thumbnails('random', 0, 1, $CONFIG['thumbcols'], 1, false);
    $random_pics = ob_get_clean();
    $fullsize_html .= $random_pics;
giving the same display as attached. can u suggest me what to do.

Thank you

 
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: random images on full image view
« Reply #5 on: January 22, 2011, 10:40:57 am »

can u suggest me what to do.
Please give more information what exactly you want to see above the full-sized picture. I don't want to create custom code which again doesn't fit your needs.
Logged

mahesh1825

  • Coppermine newbie
  • Offline Offline
  • Posts: 12
Re: random images on full image view
« Reply #6 on: January 22, 2011, 11:11:14 am »

The full page image display template should be as shown in the attachment. the no of random images should be determined by us (i mean not a fixed value). just random images are enough no tags like in index page(i.e random title) not required.

any how i managed to place a footer link on full image display page.

i hope you understand the need.



Logged

mahesh1825

  • Coppermine newbie
  • Offline Offline
  • Posts: 12
Re: random images on full image view
« Reply #7 on: January 25, 2011, 05:16:26 am »

Any one got solution?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: random images on full image view
« Reply #8 on: January 25, 2011, 10:48:48 am »

I can't able to fix it. by editing.
Code: [Select]
ob_start();
    display_thumbnails('random', 0, 1, $CONFIG['thumbcols'], 1, false);
    $random_pics = ob_get_clean();
    $fullsize_html .= $random_pics;
giving the same display as attached. can u suggest me what to do.
Replace the code with this one:
Code: [Select]
    ob_start();
    display_thumbnails('random', 0, 1, $CONFIG['thumbcols'], 1, false);
    $random_pics = ob_get_clean();
    preg_match_all('/(<a.*<\/a>)/Usi', $random_pics, $matches);
    foreach($matches[0] as $pic) {
        $fullsize_html .= str_replace('<br />', '', $pic).' ';
    }
    $fullsize_html .= '<br /><br />';
Logged

mahesh1825

  • Coppermine newbie
  • Offline Offline
  • Posts: 12
Re: random images on full image view
« Reply #9 on: January 25, 2011, 02:25:21 pm »

Is there any chance to align it to center?

Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: random images on full image view
« Reply #10 on: January 25, 2011, 02:41:48 pm »

Logged

mahesh1825

  • Coppermine newbie
  • Offline Offline
  • Posts: 12
Re: random images on full image view
« Reply #11 on: January 25, 2011, 02:45:52 pm »

Is there any chance to align it to center?
http://localhost/displayimage.php?pid=7&fullsize=1
Code: [Select]
</head>
    <body style="margin:0px; text-align:center; padding:0px; background-color: gray;">
EOT;
 ob_start();
    display_thumbnails('random', 0, 1, $CONFIG['thumbcols'], 1, false);
    $random_pics = ob_get_clean();
    preg_match_all('/(<a.*<\/a>)/Usi', $random_pics, $matches);
    foreach($matches[0] as $pic) {
        $fullsize_html .= str_replace('<br />', '', $pic).' ';
    }
    $fullsize_html .= '<br /><br />';
       

    if ($CONFIG['transparent_overlay'] == 1) {
        $fullsize_html .= <<<EOT
        <table cellpadding="0" cellspacing="0" align="center" style="padding:0px;">
            <tr>

EOT;
        $fullsize_html .=  '<td align="center" valign="middle" background="' . htmlspecialchars($imagedata['path']) . '" ' . $imagedata['geometry'] . ' class="image">';
        $fullsize_html .=  '<div id="content">';
this code i placed in template to center the random object
i changed this
Code: [Select]
<body style="margin:0px; padding:0px; background-color: gray;">into this
Code: [Select]
<body style="margin:0px; text-align:center; padding:0px; background-color: gray;">
It's working for now but is ok to use.
and another one is if i want to place this in any where with in the coppermine gallery generated pages. how can i use it like a table.?

thank you
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: random images on full image view
« Reply #12 on: January 25, 2011, 02:52:13 pm »

and another one is if i want to place this in any where with in the coppermine gallery generated pages. how can i use it like a table.?
10. One question per thread
We have a strict "One question/issue per thread rule", which helps both supporters/moderators to keep track of open/closed issues as well as users who search the board or browse it, looking for answers to their question.
If you decide to start a new thread, please post more details and follow our board rules.


It's working for now
Resolve your threads
you can tag your answer as "solved" by clicking on the little image in your initial posting on your thread.
Logged

mahesh1825

  • Coppermine newbie
  • Offline Offline
  • Posts: 12
Re: random images on full image view
« Reply #13 on: January 25, 2011, 02:58:57 pm »

i assume the align in body tag cause no harm and now its working.

thanks for support
Logged
Pages: [1]   Go Up
 

Page created in 0.039 seconds with 19 queries.