what i need is a script that will let me place X number of thumbnailed images like on the page link above but instead of them going to full sized images i want them to go to videos i plan to upload to my site
like thTF01.jpg goes to TF01.jpg i want it to go from thTF01.jpg to something like TF01.avi (or what ever format i end up with.
here is the script i use now
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
// (if imagemagick) - Path to Imagemagick "convert" program
$config['convert'] = "/usr/bin/convert";
// (if imagemagick) - Path to Imagemagick "identify" program
$config['identify'] = "/usr/bin/identify";
#######################################################################
//see if dir exits, if not create
if(isset($_GET['entry'])){
GetEntry();
}else{
PrintThumbs();
}
#######################################################################
#-#############################################
# desc: prints out html for thumbnails of images in directory
function PrintThumbs(){
global $config;
if (!file_exists($config['fulls'])) {
oops("directory <b>$config[fulls]</b> does not exist");
die;
}
//thumb directory
if (!file_exists($config['thumbs'])) {
if (!mkdir($config['thumbs'], 0755)) {
oops("Could not create thumb directory <b>$config[thumbs]</b> - check write permissions");
die;
}
}
//processing for how many images to do on current page
$config['start']=($config['page']*$config['cols']*$config['rows']);
$config['max']=( ($config['page']*$config['cols']*$config['rows']) + ($config['cols']*$config['rows']) );
// create thumb if not exist
if(!$thumb_exists){
set_time_limit(30);
$thumb_exists = ResizeImage("$config[fulls]$imagelist[$i]", $thumb_image, $config['size']);
}
//if the max cols is reached, start new col
if(($temp == $config['cols']) && ($i+1 != $config['max'])){
echo "</tr><tr><td colspan=\"$config[cols]\" class=\"spacer\"> </td></tr><tr>\n";
$temp=0;
}
$temp++;
}//foreach img
//if there are no results
if($config['start'] == $config['max']){
echo "<td align=\"center\" colspan=\"$config[cols]\" class=\"spacer\">No Entries found</td>\n";
}
//if there are empty "boxes" in the row (ie; last page)
elseif($temp != $config['cols']+1){
echo "<td align=\"center\" colspan=\"".($config['cols']-$temp+1)."\"> </td>\n";
}
echo "</tr>";
GetPageNumbers(count($imagelist));
}#-#PrintThumbs()
#-#############################################
# desc: grabs and prints filename
# returns: (bool) worked
function GetEntry(){
global $config;
if(!file_exists("$config[fulls]$_GET[entry]")){
oops("Entry does not exist");
return false;
}
#-#############################################
# desc: GetFileList
# param: [optional] directory to look through
# returns: array with list of images
function GetFileList($dirname="."){
global $config;
$list = array();
if ($handle = opendir($dirname)) {
while (false !== ($file = readdir($handle))) {
if (preg_match("/\.(jpe?g|gif|png)$/i",$file)) {
$list[] = $file;
}
}
closedir($handle);
}
sort($list);
return $list;
}#-#GetFileList()
#-#############################################
# desc: throw an error message
# param: [optional] any custom error to display
function oops($msg) {
?>
<table align=center>
<tr><td class=header>
Error
</td></tr>
<tr><td class=entry>
<br><?=$msg?>
<br><br>
<hr size=1 noshade width="80%" class=desc>
<center>Please hit the <a href="javaScript:history.back();"><b>back button</b></a> on your browser to try again.</center>
</td></tr></table>
<?php
}#-#oops()
#-#############################################
# desc: chooses method to resize image to correct ratio
# param: ($image) image reference of full size img to use ($newimage) what to save thumbnail as ($size) max width or height to resize to
# returns: (bool) if image was created
function ResizeImage($image, $newimage, $size) {
global $config;
switch ($config['imagemethod']) {
case "imagemagick":
return ResizeImageUsingIM($image, $newimage, $size);
break;
case "gd1":
case "gd2":
return ResizeImageUsingGD($image, $newimage, $size);
break;
default:
return false;
break;
}
}#-#ResizeImage()
#-#############################################
# desc: resizes image if GD was used
# param: ($image) image reference of full size img to use ($newimage) what to save thumbnail as ($size) max width or height to resize to
# returns: (bool) if image was created
function ResizeImageUsingGD($image, $newimage, $size) {
list ($width,$height,$type) = GetImageSize($image);
if($im = ReadImageFromFile($image,$type)){
//if image is smaller than the $size, make it actual $size
if($height < $size && $width < $size){
$newheight=$height;
$newwidth=$width;
}
//if image height is larger, height=$size, then calc width
else if($height > $width){
$newheight=$size;
$newwidth=($width / ($height/$size));//cast the resized width as int
}
//if image width is larger, width=$size, then calc width
else{
$newwidth=$size;
$newheight=($height / ($width/$size));//cast the resized height as int
}
#-#############################################
# desc: resizes image using imagemagick
# param: ($image) image reference of full size img to use ($newimage) what to save thumbnail as ($size) max width or height to resize to
# returns: (bool) if image was created
function ResizeImageUsingIM($image, $newimage, $size) {
global $config;
//if image is smaller than the 160 container, make it actual size
if($height < $size && $width < $size){
$newheight=$height;
$newwidth=$width;
}
//if image height is larger, height=$size, then calc width
else if($height > $width){
$newheight=$size;
$newwidth=($width / ($height/$size));//cast the resized width as int
}
//if image width is larger, width=$size, then calc width
else{
$newwidth=$size;
$newheight=($height / ($width/$size));//cast the resized height as int
}
#-#############################################
# desc: resizes image using imagemagick
# param: ($filename) filename of image to create ($type) int of type. 1=gif,2=jpeg,3=png
# returns: binary img
function ReadImageFromFile($filename, $type) {
$imagetypes = ImageTypes();
switch ($type) {
case 1 :
if ($imagetypes & IMG_GIF){
return $im = ImageCreateFromGIF($filename);
}
break;
case 2 :
if ($imagetypes & IMG_JPEG){
return ImageCreateFromJPEG($filename);
}
break;
case 3 :
if ($imagetypes & IMG_PNG){
return ImageCreateFromPNG($filename);
}
break;
default:
return 0;
}
}#-#ReadImageFromFile()
#-#############################################
# desc: resizes image using imagemagick
# returns: binary img
function WriteImageToFile($im, $filename, $type) {
global $config;
switch ($type) {
case 1 :
return ImageGIF($im, $filename);
case 2 :
return ImageJpeg($im, $filename, $config['imagequality']);
case 3 :
return ImagePNG($im, $filename);
default:
return false;
}
}#-#WriteImageToFile()
#-#############################################
# sub: GetPageNumbers
# desc: gets the pages in the list
function GetPageNumbers($entries) {
global $config;
// echo number of pages
echo "<tr><td colspan=$config[cols] align=center height=20 class=border>Page ($config[totalPages]): ";
// echo out PREV
if( ($config['page']-1) >= 0){
echo "<a href=\"$_SERVER[SCRIPT_NAME]?page=".($config['page']-1)."\" class=page><b>«Prev</b></a>";}
// else no link
else{echo "<b>«Prev</b>";}
// for each link, echo out page link
$start=0; // starting image number
$end=$config['totalPages']-1; // ending image number (total / number image on page)
// echo out each of the numbers
for($i=$start; $i<=$end ; $i++){
if($config['page']==$i){echo "<b>[".($i+1)."]</b> \n";}
else{echo "<a href=\"$_SERVER[SCRIPT_NAME]?page=$i\" class=page><b>".($i+1)."</b></a> \n";}
}
really what i am looking for is a way to upload videos to a folder or folders and the script will show like maybe 6 videos per page. my visitors can then click on a video thumbnail and it will open in their player.would use a youtube like script however i do not like all their features and i don't like their layout
see i like how windows does things however i cant use something like that.
sorry for replying to my own thread here i really haddent entended on this however i can see how confusing my original post can be... the reason i posted the image gallery script i use is i was hoping that could be modified to do what i wanted with the video section of my site. .. i like the layout and feel of that script. if nothing else it will give you an idea of how i want things to look.
i think six videos per page will be fine as most people have some sort of broad band connection and can still load in fast enough my current thumbs for the index.php page are 241x142 and i was thinking make the video thumbs double that size and have just two videos per row and have three rows of them or maybe just two by two. the spacing for the thumbs can be the same as it is for my index page though.
Last edited by Mike Anime; 07-12-09 at 03:51 PM.
Reason: to better explain what i want more clearly