Jump to content

[SOLVED] I need some help with a pop-up window for pictures.


vetman

Recommended Posts

I have a script that reads a directory of pictures, makes thumbnails of the pictures. It then show them in the broser. When I click the picture it shows the larger picture in the broser. I want to pop-up another window with the picture in it. I have a javascript file that does that, but I can't figure out how to make it work with this script.

Listed below is my attempt, not show all the script:

 

 

function getNormalImage($file){

    $base = substr($file,0,strrpos($file,'_th.jpg'));

    if (file_exists($base.'.jpg')) return $base.'.jpg';

    elseif (file_exists($base.'.jpeg')) return $base.'.jpeg';

    else return "";

}

 

function displayPhotos(){

    global $columns;

 

    generateThumbnails();

    $act = 0;

    // Open the actual directory

    if ($handle = opendir(".")) {

        // Read all file from the actual directory

        while ($file = readdir($handle))  {

            // Check whether tha actual item is a valid file

            if (is_file($file)){

                // Check whether the actual image is a thumbnail

                  if (strpos($file,'_th.jpg')){

                    ++$act;

                    if ($act > $columns) {

                        echo '</tr><tr>

                          <td class="photo"><a href="'.getNormalImage($file).'" onClick='return showpic("'.getNormalImage($file).'",,);'><img src="'.$file.'" alt="'.$file.'"/></a></td>';

                        $act = 1;

                    } else {

                        echo '<td class="photo"><a href="'.getNormalImage($file).'">

                          <img src="'.$file.'" alt="'.$file.'"/></a></td>';

                    }

 

                  }

              }

        }

    }

}

 

 

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

    "DTD/xhtml1-transitional.dtd">

<html>

<head>

  <title>Photo Gallery</title>

 

  <script language="javascript">

 

  function showpic(picurl,width,height) {

          picwindow = window.open('', 'pic', 'resizable,height=' + (height+70) + ',width=' + (width+20));

          picwindow.document.write('<HTML><BODY  bgcolor="66cc99">\n');

          picwindow.document.write('<TABLE border=0 cellpadding=0 cellspacing=0>\n');

          picwindow.document.write('<TR><TD><IMG SRC="' + picurl + '" WIDTH=' + width + ' HEIGHT=' + height + ' BORDER=0></TD></TR>\n');

          picwindow.document.write('</TABLE>\n');

          picwindow.document.write('<br><center><A href="javascript:self.close()"><B>Close Window</B></A></center>\n');

          picwindow.document.write('</BODY></HTML>\n');

          return false;

          }

  // If we are on NetScape, we can bring the window to the front

          if (navigator.appName.substring(0,8) == "Netscape") picwindow.focus();

 

</script>

</head>

<body>

  <center><h3>Photo Gallery</h3></center>

  <table align="center"><tr>

    <?php displayPhotos(); ?>

  </table>

</body>

 

</html>

 

Any help or direction would be appreciated.

Thanks in advance.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.