473,405 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Create thumbnails with clickable links XYZ

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">&nbsp;</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">&nbsp;</div>

<table border="0" cellspacing="5" cellpadding="0" align="center">
<tr>
<td><a href="<?php print $weed; ?>?filex=jpg" class="thumbnav">&lt; JPG
&gt;</a></td>
<td><a href="<?php print $weed; ?>?filex=gif" class="thumbnav">&lt; GIF
&gt;</a></td>
<td><a href="<?php print $weed; ?>?filex=png" class="thumbnav">&lt; PNG
&gt;</a></td>
</tr>
</table>

<div align="center" class="gap5">&nbsp;</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>&nbsp</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>

Oct 30 '06 #1
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">&nbsp;</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">&nbsp;</div>

<table border="0" cellspacing="5" cellpadding="0" align="center">
<tr>
<td><a href="<?php print $weed; ?>?filex=jpg" class="thumbnav">&lt; JPG
&gt;</a></td>
<td><a href="<?php print $weed; ?>?filex=gif" class="thumbnav">&lt; GIF
&gt;</a></td>
<td><a href="<?php print $weed; ?>?filex=png" class="thumbnav">&lt; PNG
&gt;</a></td>
</tr>
</table>

<div align="center" class="gap5">&nbsp;</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>&nbsp</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>
Oct 30 '06 #2
<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
Oct 30 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
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...
0
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)...
6
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...
8
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:...
3
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...
7
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...
3
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...
11
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,...
1
momotaro
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
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,...
0
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...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.