random images on full image view random images on full image view
 

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]

Main Menu

random images on full image view

Started by mahesh1825, January 21, 2011, 04:09:06 PM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

mahesh1825

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

Αndré

Open themes/yourtheme/theme.php and copy the following code right before the
?>
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:
    ob_start();
    display_thumbnails('random', 0, 1, $CONFIG['thumbcols'], 1, false);
    $random_pics = ob_get_clean();
    $fullsize_html .= $random_pics;

mahesh1825

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.


Αndré

Use this code:
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;
}


Quote from: mahesh1825 on January 21, 2011, 04:52:09 PM
little bit deformed page
Yes, that's why I said:
Quote from: Αndré on January 21, 2011, 04:32:49 PM
This probably doesn't look as you want, so you have to adjust that part:
    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.

mahesh1825

I can't able to fix it. by editing.
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


Αndré

Quote from: mahesh1825 on January 22, 2011, 05:53:35 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.

mahesh1825

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.




mahesh1825


Αndré

Quote from: mahesh1825 on January 22, 2011, 05:53:35 AM
I can't able to fix it. by editing.
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:
    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 />';

mahesh1825

Is there any chance to align it to center?


Αndré


mahesh1825

Quote from: mahesh1825 on January 25, 2011, 02:25:21 PM
Is there any chance to align it to center?
http://localhost/displayimage.php?pid=7&fullsize=1
</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
<body style="margin:0px; padding:0px; background-color: gray;">
into this
<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

Αndré

Quote from: mahesh1825 on January 25, 2011, 02:45:52 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.?
Quote from: Joachim Müller on September 28, 2008, 10:28:42 AM
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.


Quote from: mahesh1825 on January 25, 2011, 02:45:52 PM
It's working for now
Quote from: Joachim Müller on September 28, 2008, 12:46:26 PM
Resolve your threads
you can tag your answer as "solved" by clicking on the little image in your initial posting on your thread.

mahesh1825

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

thanks for support