Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > PHP

Reply
 
LinkBack Thread Tools Display Modes
Old 12-19-2007, 04:28 PM   #1 (permalink)
justin2008206
Recruit
 
Join Date: Dec 2007
Posts: 1
justin2008206 is on a distinguished road
Question how to add page support to a photo gallery script

I'v got this script to display all the pictures
in a directory, it works fine. The problem is
that I have too many of them to be show on one
page, so I like to add page support to the script
and number of pictures per page. and i don't know
how to go by doin this. can any help me whit this and show me how i can do it and can it be done whit this script please help

here the script

<?php
$thumb_width = 80;
$thumb_height = 60;
$col = 6;

function resizeImage($originalImage,$tWidth,$tHeight){

list($width, $height) = getimagesize($originalImage);
$xscale=$width/$tWidth;
$yscale=$height/$tHeight;


if ($yscale>$xscale){
$newwidth = round($width * (1/$yscale));
$newheight = round($height * (1/$yscale));
}
else {
$newwidth = round($width * (1/$xscale));
$newheight = round($height * (1/$xscale));
}

$imageResized = imagecreatetruecolor($newwidth, $newheight);
$imageTmp = imagecreatefromjpeg ($originalImage);
imagecopyresampled($imageResized, $imageTmp, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

return $imageResized;
}

function generateThumbnails(){
global $thumb_width,$thumb_height;
if ($handle = opendir(".")) {
while ($file = readdir($handle)) {
if (is_file($file)){
if (strpos($file,'_rg.jpg')){
$isThumb = true;
} else {
$isThumb = false;
}

if (!$isThumb) {
$dirName = substr($file,0,strpos($file,basename($file)));
if (strlen($dirName) < 1) $dirName = '.';
$fileName = basename($file);
$fileMain = substr($fileName,0,strrpos($fileName,'.'));
$extName = substr($fileName,strrpos($fileName,'.'),
strlen($fileName)-strrpos($fileName,'.'));


if (($extName == '.jpg') || ($extName == '.jpeg')){
$thmbFile = $dirName.'/'.$fileMain.'_rg.jpg';

if (!file_exists($thmbFile)){
imagejpeg(resizeImage($file,$thumb_width,$thumb_he ight),$thmbFile,80);
}
}
}
}
}
}

}

function getNormalImage($file){
$base = substr($file,0,strrpos($file,'_rg.jpg'));
if (file_exists($base.'.jpg')) return $base.'.jpg';
elseif (file_exists($base.'.jpeg')) return $base.'.jpeg';
else return "";
}

function displayPhotos(){
global $col;

generateThumbnails();
$act = 0;
if ($handle = opendir(".")) {

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

if (is_file($file)){

if (strpos($file,'_rg.jpg')){
++$act;
if ($act > $col) {
echo '</tr><tr><td class="photo"><div class="thumbsBox"><a href="view.php?image='.getNormalImage($file).'"><i mg src="'.$file.'" alt="'.$file.'"/></a></td>';
$act = 1;
} else {
echo '<td class="photo"><div class="thumbsBox"><a href="view.php?image='.getNormalImage($file).'"><i mg src="'.$file.'" alt="'.$file.'"/></a></td>';
}

}
}
}
}
}

?>
<html>
<head>
<link rel="stylesheet" href="images/styles.css" type="text/css" media="screen">
</head>
<body>
<title>Photo Gallery</title>
<div>
<div id="pic" style="position:absolute; left:0px; top:0px;">
<img src="images/header1.jpg" border=0 width=780 height=100>
</div>
<div id="pic" style="position:absolute; left:0px; top:100px;">
<img src="images/counter.jpg" border=0 width=780 height=34></div>
<br><br><br><br><br><br><br><br><br><br><br>
<hr WIDTH="100%" SIZE="1">
<u><a href=" http://.com"title="Copyright 2006-2007Copyrights And Trademarks Are Property Of Their Respective Owners. All Rights Reserved."class="rgstyle"><font size=2 color="#FF0000">Copyright 2006-2007 RippedGames Inc.</a><div>All Other Copyrights And Trademarks Are Property Of Their Respective Owners. All Rights Reserved.</u></center>
</body>
justin2008206 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I add a stylesheet to this script? mio HTML, XML, Javascript, AJAX 3 03-24-2005 10:29 AM


All times are GMT -8. The time now is 06:31 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting