The question of how to create thumbnails with clickable links gets asked
on this newsgroup every so often - like clock work .
Just really posing this script here for google to archive it & so users
can be pointed to it in the future via a link to google groups .
<html>
<head>
<title>thumbnails.php</title>
</head>
<style type="text/css">
body {margin-bottom : 0px;margin-left : 0px; margin-right : 0px;
margin-top : 0px;}
A:link {text-decoration: none;}
A:visited {text-decoration: none;}
A:active {text-decoration: none;}
A:hover {text-decoration : underline;}
..backy{background-color: #FFEEFF;}
..gap1{font-size: 1px;}
..gap2{font-size: 2px;}
..gap3{font-size: 3px;}
..gap4{font-size: 4px;}
..gap5{font-size: 5px;}
..gap6{font-size: 6px;}
..gap7{font-size: 7px;}
..gap8{font-size: 8px;}
..gap9{font-size: 9px;}
..tap
{
color : Black; background-color: #F9FBFB;
font-size : 20pt; font-family : Arial;
padding-left: 22px; padding-right: 22px; padding-top: 3px; padding-
bottom: 3px;
border: 1px solid #CFD1F1;
}
..box
{
background-color: #FFEFFF;
padding-left: 2px; padding-right: 2px; padding-top: 2px; padding-bottom:
2px;
border: 1px solid #FEDAFE;
}
..bar
{
background-color: #F5DDFF;
padding-left: 5px; padding-right: 5px; padding-top: 0px; padding-bottom:
3px;
border: 1px solid #DADBD1;
}
..thumbnav
{
color: #000000; background-color: #F4DEDE;
font-size: 10pt; font-family: Arial; text-align: center;
padding-left: 9px; padding-right: 9px; padding-top: 4px; padding-bottom:
4px;
}
..thumbnav:hover
{
text-decoration: none;
color: #000000; background: #FFFFC0;
}
..mma{color : Maroon; font-size : 8pt;font-family : Arial;}
..mmb{color : Maroon; font-size : 10pt;font-family : Arial;}
..mmc{color : Maroon; font-size : 12pt;font-family : Arial;}
..mmd{color : Maroon; font-size : 14pt;font-family : Arial;}
..bba{color : Black; font-size : 8pt;font-family : Arial;}
..bbb{color : black; font-size : 10pt;font-family : Arial;}
..bbc{color : Black; font-size : 12pt;font-family : Arial;}
..bbd{color : Black; font-size : 14pt;font-family : Arial;}
..nna{color : Navy; font-size : 8pt;font-family : Arial;}
..nnb{color : Navy; font-size : 10pt;font-family : Arial;}
..nnc{color : Navy; font-size : 12pt;font-family : Arial;}
..nnd{color : Navy; font-size : 14pt;font-family : Arial;}
..rra{color : Red;font-size : 8pt;font-family : Arial;}
..rrb{color : Red;font-size : 10pt;font-family : Arial;}
..rrc{color : Red;font-size : 12pt;font-family : Arial;}
..rrd{color : Red;font-size : 14pt;font-family : Arial;}
</style>
<body class="backy">
<?php
$weed=basename($_SERVER['PHP_SELF']);
$dir="test/images"; $columns=6;
$ext=".jpg";
# .jpg .gif .png , You can use any of these 3 image extensions , But not
more than one at a time .
$what=$_REQUEST['filex']; $what=strtolower($what);
if ($what<>"")
{
if ($what=="jpg") {$ext=".jpg";}
if ($what=="gif") {$ext=".gif";}
if ($what=="png") {$ext=".png";}
}
$thumbext="_thumb" . "$ext";
$whatupper=str_replace(".","",$ext); $whatupper=strtoupper($whatupper);
?>
<div align="center" class="gap9"> </div>
<table border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td class="tap">THUMBNAILS - <?php print $whatupper; ?></td>
</tr>
</table>
<div align="center" class="gap5"> </div>
<table border="0" cellspacing="5" cellpadding="0" align="center">
<tr>
<td><a href="<?php print $weed; ?>?filex=jpg" class="thumbnav">< JPG
></a></td>
<td><a href="<?php print $weed; ?>?filex=gif" class="thumbnav">< GIF
></a></td>
<td><a href="<?php print $weed; ?>?filex=png" class="thumbnav">< PNG
></a></td>
</tr>
</table>
<div align="center" class="gap5"> </div>
<?php
$batman=0;
$joker=opendir($dir);
while (false!==($boywonder=readdir($joker)))
{
$files[]=$boywonder;
$batman=$batman+1;
}
$temp=0;
while ($temp<$batman)
{
$demo=$files[$temp];
$riddler=strlen($demo);
$penguin=substr($demo,$riddler-4,4);
$catwoman=substr($demo,$riddler-10,10);
$img_name="$dir" . "/" . "$demo";
$thumb_name=str_replace($ext,$thumbext,$img_name);
if ($penguin==$ext && $catwoman<>$thumbext)
{
$pass=1;
$filename=$thumb_name;
if (!file_exists($filename)) {$pass=0;}
if ($pass==0)
{
$max_width=150; $max_height=80;
$size=GetImageSize($img_name);
$width_ratio=($size[0] / $max_width); $height_ratio=($size[1] /
$max_height);
if ($width_ratio>=$height_ratio) {$ratio=$width_ratio;} else {$ratio=
$height_ratio;}
$new_width=($size[0] / $ratio); $new_height=($size[1] / $ratio);
if ($ext==".jpg") {$src_img=ImageCreateFromJPEG($img_name);}
if ($ext==".gif") {$src_img=ImageCreateFromGIF($img_name);}
if ($ext==".png") {$src_img=ImageCreateFromPNG($img_name);}
$thumb=ImageCreateTrueColor($new_width,$new_height );
ImageCopyResampled($thumb,$src_img,0,0,0,0,($new_w idth-1),($new_height-
1),$size[0],$size[1]);
ImageJPEG($thumb,$thumb_name,100);
ImageDestroy($src_img);
ImageDestroy($thumb);
}
}
$temp=$temp+1;
}
$homer=0;
$joker=opendir($dir);
while (false!==($boywonder=readdir($joker)))
{
$marge[]=$boywonder;
$homer=$homer+1;
}
$lisa=0;
$temp=0;
while ($temp<$homer)
{
$demo=$marge[$temp];
$riddler=strlen($demo);
$penguin=substr($demo,$riddler-4,4);
$catwoman=substr($demo,$riddler-10,10);
if ($catwoman==$thumbext)
{
$thumb_name="$dir" . "/" . "$demo";
$img_name=str_replace($thumbext,$ext,$thumb_name);
$millhouse[$lisa]=$thumb_name;
$diamondjoe[$lisa]=$img_name;
$lisa=$lisa+1;
}
$temp=$temp+1;
}
?>
<?php
print "<table border=0 cellspacing=1 cellpadding=0 align=center>";
$loopy=0;
while ($loopy<$lisa)
{
print "<tr valign=top>";
$tempxx=0;
while ($tempxx<$columns)
{
if ($loopy<$lisa)
{
$passimage=1;
$filename=$diamondjoe[$loopy];
if (!file_exists($filename)) {$passimage=0;}
if ($passimage==0)
{
print "<td class=box>";
print "$filename";
print "<br>";
print "<span class=rrb>FILE NOT FOUND</span>";
print "<br><br>";
print "<span class=mma>DELETE THE FOLLOWING FILE</span>";
print "<br>";
print "<span class=nnb>$millhouse[$loopy]</span>";
print "<br>";
print "<span class=mma>TO PREVENT THIS ERROR FROM HAPPENING</span>";
print "</td>";
}
if ($passimage==1)
{
$moe=filesize($diamondjoe[$loopy]);
$ralph=$moe;
$wiggum=strlen($moe);
if ($ralph>999) {$ralph=substr($ralph,0,$wiggum-3);} else {$ralph="?";}
$barney="$ralph" . "k";
$apu=GetImageSize($diamondjoe[$loopy]);
$size=GetImageSize($millhouse[$loopy]);
$duffbeer=$loopy+1;
print "<td class=box>";
print "<div align=left class=bar><span class=nna>($duffbeer)</span>
<span class=bba>$apu[0] x $apu[1]</span<span class=mma>$barney</span>
</div>";
print "";
print "<div align=center class=gap3> </div>";
print "<a href=$diamondjoe[$loopy]><img src=$millhouse[$loopy] width=
$size[0] height=$size[1] border=0></a><br>";
print "</td>";
}
}
$tempxx=$tempxx+1;
$loopy=$loopy+1;
}
print "</tr>";
}
print "</table>";
?>
</body>
</html> 2 2043
This must be the worst naming of variables and functions I've seen in a
long time. I would absolutely refuse to work with this code if I found
it in a commercial project. Lets hope nobody every points to this post,
shall we.
On Oct 30, 1:59 am, Krustov <m...@privacy.netwrote:
The question of how to create thumbnails with clickable links gets asked
on this newsgroup every so often - like clock work .
Just really posing this script here for google to archive it & so users
can be pointed to it in the future via a link to google groups .
<html>
<head>
<title>thumbnails.php</title>
</head>
<style type="text/css">
body {margin-bottom : 0px;margin-left : 0px; margin-right : 0px;
margin-top : 0px;}
A:link {text-decoration: none;}
A:visited {text-decoration: none;}
A:active {text-decoration: none;}
A:hover {text-decoration : underline;}
.backy{background-color: #FFEEFF;}
.gap1{font-size: 1px;}
.gap2{font-size: 2px;}
.gap3{font-size: 3px;}
.gap4{font-size: 4px;}
.gap5{font-size: 5px;}
.gap6{font-size: 6px;}
.gap7{font-size: 7px;}
.gap8{font-size: 8px;}
.gap9{font-size: 9px;}
.tap
{
color : Black; background-color: #F9FBFB;
font-size : 20pt; font-family : Arial;
padding-left: 22px; padding-right: 22px; padding-top: 3px; padding-
bottom: 3px;
border: 1px solid #CFD1F1;
}.box
{
background-color: #FFEFFF;
padding-left: 2px; padding-right: 2px; padding-top: 2px; padding-bottom:
2px;
border: 1px solid #FEDAFE;
}.bar
{
background-color: #F5DDFF;
padding-left: 5px; padding-right: 5px; padding-top: 0px; padding-bottom:
3px;
border: 1px solid #DADBD1;
}.thumbnav
{
color: #000000; background-color: #F4DEDE;
font-size: 10pt; font-family: Arial; text-align: center;
padding-left: 9px; padding-right: 9px; padding-top: 4px; padding-bottom:
4px;
}.thumbnav:hover
{
text-decoration: none;
color: #000000; background: #FFFFC0;
}.mma{color : Maroon; font-size : 8pt;font-family : Arial;}
.mmb{color : Maroon; font-size : 10pt;font-family : Arial;}
.mmc{color : Maroon; font-size : 12pt;font-family : Arial;}
.mmd{color : Maroon; font-size : 14pt;font-family : Arial;}
.bba{color : Black; font-size : 8pt;font-family : Arial;}
.bbb{color : black; font-size : 10pt;font-family : Arial;}
.bbc{color : Black; font-size : 12pt;font-family : Arial;}
.bbd{color : Black; font-size : 14pt;font-family : Arial;}
.nna{color : Navy; font-size : 8pt;font-family : Arial;}
.nnb{color : Navy; font-size : 10pt;font-family : Arial;}
.nnc{color : Navy; font-size : 12pt;font-family : Arial;}
.nnd{color : Navy; font-size : 14pt;font-family : Arial;}
.rra{color : Red;font-size : 8pt;font-family : Arial;}
.rrb{color : Red;font-size : 10pt;font-family : Arial;}
.rrc{color : Red;font-size : 12pt;font-family : Arial;}
.rrd{color : Red;font-size : 14pt;font-family : Arial;}
</style>
<body class="backy">
<?php
$weed=basename($_SERVER['PHP_SELF']);
$dir="test/images"; $columns=6;
$ext=".jpg";
# .jpg .gif .png , You can use any of these 3 image extensions , But not
more than one at a time .
$what=$_REQUEST['filex']; $what=strtolower($what);
if ($what<>"")
{
if ($what=="jpg") {$ext=".jpg";}
if ($what=="gif") {$ext=".gif";}
if ($what=="png") {$ext=".png";}
}$thumbext="_thumb" . "$ext";
$whatupper=str_replace(".","",$ext); $whatupper=strtoupper($whatupper);
?>
<div align="center" class="gap9"> </div>
<table border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td class="tap">THUMBNAILS - <?php print $whatupper; ?></td>
</tr>
</table>
<div align="center" class="gap5"> </div>
<table border="0" cellspacing="5" cellpadding="0" align="center">
<tr>
<td><a href="<?php print $weed; ?>?filex=jpg" class="thumbnav">< JPG
></a></td>
<td><a href="<?php print $weed; ?>?filex=gif" class="thumbnav">< GIF
></a></td>
<td><a href="<?php print $weed; ?>?filex=png" class="thumbnav">< PNG
></a></td>
</tr>
</table>
<div align="center" class="gap5"> </div>
<?php
$batman=0;
$joker=opendir($dir);
while (false!==($boywonder=readdir($joker)))
{
$files[]=$boywonder;
$batman=$batman+1;
}$temp=0;
while ($temp<$batman)
{
$demo=$files[$temp];
$riddler=strlen($demo);
$penguin=substr($demo,$riddler-4,4);
$catwoman=substr($demo,$riddler-10,10);
$img_name="$dir" . "/" . "$demo";
$thumb_name=str_replace($ext,$thumbext,$img_name);
if ($penguin==$ext && $catwoman<>$thumbext)
{
$pass=1;
$filename=$thumb_name;
if (!file_exists($filename)) {$pass=0;}
if ($pass==0)
{
$max_width=150; $max_height=80;
$size=GetImageSize($img_name);
$width_ratio=($size[0] / $max_width); $height_ratio=($size[1] /
$max_height);
if ($width_ratio>=$height_ratio) {$ratio=$width_ratio;} else {$ratio=
$height_ratio;}
$new_width=($size[0] / $ratio); $new_height=($size[1] / $ratio);
if ($ext==".jpg") {$src_img=ImageCreateFromJPEG($img_name);}
if ($ext==".gif") {$src_img=ImageCreateFromGIF($img_name);}
if ($ext==".png") {$src_img=ImageCreateFromPNG($img_name);}
$thumb=ImageCreateTrueColor($new_width,$new_height );
ImageCopyResampled($thumb,$src_img,0,0,0,0,($new_w idth-1),($new_height-
1),$size[0],$size[1]);
ImageJPEG($thumb,$thumb_name,100);
ImageDestroy($src_img);
ImageDestroy($thumb);
}
}$temp=$temp+1;
}$homer=0;
$joker=opendir($dir);
while (false!==($boywonder=readdir($joker)))
{
$marge[]=$boywonder;
$homer=$homer+1;
}$lisa=0;
$temp=0;
while ($temp<$homer)
{
$demo=$marge[$temp];
$riddler=strlen($demo);
$penguin=substr($demo,$riddler-4,4);
$catwoman=substr($demo,$riddler-10,10);
if ($catwoman==$thumbext)
{
$thumb_name="$dir" . "/" . "$demo";
$img_name=str_replace($thumbext,$ext,$thumb_name);
$millhouse[$lisa]=$thumb_name;
$diamondjoe[$lisa]=$img_name;
$lisa=$lisa+1;
}$temp=$temp+1;
}?>
<?php
print "<table border=0 cellspacing=1 cellpadding=0 align=center>";
$loopy=0;
while ($loopy<$lisa)
{
print "<tr valign=top>";
$tempxx=0;
while ($tempxx<$columns)
{
if ($loopy<$lisa)
{
$passimage=1;
$filename=$diamondjoe[$loopy];
if (!file_exists($filename)) {$passimage=0;}
if ($passimage==0)
{
print "<td class=box>";
print "$filename";
print "<br>";
print "<span class=rrb>FILE NOT FOUND</span>";
print "<br><br>";
print "<span class=mma>DELETE THE FOLLOWING FILE</span>";
print "<br>";
print "<span class=nnb>$millhouse[$loopy]</span>";
print "<br>";
print "<span class=mma>TO PREVENT THIS ERROR FROM HAPPENING</span>";
print "</td>";
}if ($passimage==1)
{
$moe=filesize($diamondjoe[$loopy]);
$ralph=$moe;
$wiggum=strlen($moe);
if ($ralph>999) {$ralph=substr($ralph,0,$wiggum-3);} else {$ralph="?";}
$barney="$ralph" . "k";
$apu=GetImageSize($diamondjoe[$loopy]);
$size=GetImageSize($millhouse[$loopy]);
$duffbeer=$loopy+1;
print "<td class=box>";
print "<div align=left class=bar><span class=nna>($duffbeer)</span>
<span class=bba>$apu[0] x $apu[1]</span<span class=mma>$barney</span>
</div>";
print "";
print "<div align=center class=gap3> </div>";
print "<a href=$diamondjoe[$loopy]><img src=$millhouse[$loopy] width=
$size[0] height=$size[1] border=0></a><br>";
print "</td>";
}
}$tempxx=$tempxx+1;
$loopy=$loopy+1;
}print "</tr>";
}print "</table>";
?>
</body>
</html>
<comp.lang.php>
<ha*************@gmail.com>
<30 Oct 2006 06:58:33 -0800>
<11**********************@m7g2000cwm.googlegroups. com>
This must be the worst naming of variables and functions I've seen in a
long time. I would absolutely refuse to work with this code if I found
it in a commercial project. Lets hope nobody every points to this post,
shall we.
Tickled yer fancy did it :-)
-- www.phpchatroom.co.uk This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rednelle |
last post by:
Greetings all,
As a newbie, using Access 2000, I would appreciate advice on the best
way to include pictures.
I have developed a 'Home Inventory' database which can include jpeg
thumbnails of...
|
by: Showjumper |
last post by:
I have seen the article on 4 guys that descibes creating an event calandar.
However what i would like to do is have the days be clickable (i.e. click
the day and it show the details for that event)...
|
by: Rich |
last post by:
Hello,
I want to simulate the dynamic thumbnail display of Windows Explorer (winxp)
on a form or pannel container. If I place a picture box on my container
form/pannel and dimension it to the...
|
by: barb |
last post by:
So that the world at large benefits from our efforts, here is one fully
documented way to use Windows Irfanview freeware to create thumbnail web
galleries (http://www.irfanview.com).
STEP 1:...
|
by: divina11 |
last post by:
I'm wanting a html page with a series of thumbnails which are clickable to enlarge the image in a new window, how do you do this?
Currently I have the images in the following format.
<p>
An...
|
by: Jeff Gaines |
last post by:
I have spent the day learning how to use Zend Development Environment. I
can now produce a list of files in a directory, filtered by extension, and
apparently clickable. Unfortunately clicking on...
|
by: breakupemail |
last post by:
Hello, on my website at http://www.breakupemail.com/ there is a horizontal navigation bar with 6 hyperlinks. Recently, I added a second navigation row below the first, with 2 links. Once this...
|
by: =?Utf-8?B?UGV0ZXIgSw==?= |
last post by:
I am working with Visual Studio or alternately with Expression Web. I need
to create about 50 aspx pages with about 1200 thumbnali images, typically
arranged in three to four groups per page,...
|
by: momotaro |
last post by:
IMPORTANT: My first time with flash and actionscript but am a computer science student so code is ok.
that said I wanna build a xml based scrolling thumbnails in an horizontal bar.
each pic...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |