Create thumbnails with clickable links XYZ

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Krustov

    #1

    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>thumbnai ls.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{backgro und-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:hove r
    {
    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=strtolowe r($what);

    if ($what<>"")
    {
    if ($what=="jpg") {$ext=".jpg";}
    if ($what=="gif") {$ext=".gif";}
    if ($what=="png") {$ext=".png";}
    }

    $thumbext="_thu mb" . "$ext";

    $whatupper=str_ replace(".","", $ext); $whatupper=strt oupper($whatupp er);

    ?>

    <div align="center" class="gap9">&n bsp;</div>

    <table border="0" cellspacing="0" cellpadding="0" align="center">
    <tr>
    <td class="tap">THU MBNAILS - <?php print $whatupper; ?></td>
    </tr>
    </table>

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

    <?php

    $batman=0;

    $joker=opendir( $dir);
    while (false!==($boyw onder=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=subst r($demo,$riddle r-10,10);

    $img_name="$dir " . "/" . "$demo";
    $thumb_name=str _replace($ext,$ thumbext,$img_n ame);

    if ($penguin==$ext && $catwoman<>$thu mbext)
    {

    $pass=1;
    $filename=$thum b_name;
    if (!file_exists($ filename)) {$pass=0;}

    if ($pass==0)
    {
    $max_width=150; $max_height=80;
    $size=GetImageS ize($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=($si ze[0] / $ratio); $new_height=($s ize[1] / $ratio);
    if ($ext==".jpg") {$src_img=Image CreateFromJPEG( $img_name);}
    if ($ext==".gif") {$src_img=Image CreateFromGIF($ img_name);}
    if ($ext==".png") {$src_img=Image CreateFromPNG($ img_name);}
    $thumb=ImageCre ateTrueColor($n ew_width,$new_h eight);
    ImageCopyResamp led($thumb,$src _img,0,0,0,0,($ new_width-1),($new_height-
    1),$size[0],$size[1]);
    ImageJPEG($thum b,$thumb_name,1 00);
    ImageDestroy($s rc_img);
    ImageDestroy($t humb);
    }

    }

    $temp=$temp+1;
    }



    $homer=0;

    $joker=opendir( $dir);
    while (false!==($boyw onder=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=subst r($demo,$riddle r-10,10);

    if ($catwoman==$th umbext)
    {
    $thumb_name="$d ir" . "/" . "$demo";
    $img_name=str_r eplace($thumbex t,$ext,$thumb_n ame);
    $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<$colum ns)
    {

    if ($loopy<$lisa)
    {

    $passimage=1;
    $filename=$diam ondjoe[$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>DELET E THE FOLLOWING FILE</span>";
    print "<br>";
    print "<span class=nnb>$mill house[$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,$wiggu m-3);} else {$ralph="?";}
    $barney="$ralph " . "k";
    $apu=GetImageSi ze($diamondjoe[$loopy]);
    $size=GetImageS ize($millhouse[$loopy]);
    $duffbeer=$loop y+1;
    print "<td class=box>";
    print "<div align=left class=bar><span class=nna>($duf fbeer)</span>
    <span class=bba>$apu[0] x $apu[1]</span<span class=mma>$barn ey</span>
    </div>";
    print "";
    print "<div align=center class=gap3>&nbs p</div>";
    print "<a href=$diamondjo e[$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>



  • hakan.magnusson@gmail.com

    #2
    Re: Create thumbnails with clickable links XYZ

    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.n etwrote:
    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>thumbnai ls.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{backgrou nd-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:hove r
    {
    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=strtolowe r($what);
    >
    if ($what<>"")
    {
    if ($what=="jpg") {$ext=".jpg";}
    if ($what=="gif") {$ext=".gif";}
    if ($what=="png") {$ext=".png";}
    >
    }$thumbext="_th umb" . "$ext";
    >
    $whatupper=str_ replace(".","", $ext); $whatupper=strt oupper($whatupp er);
    >
    ?>
    >
    <div align="center" class="gap9">&n bsp;</div>
    >
    <table border="0" cellspacing="0" cellpadding="0" align="center">
    <tr>
    <td class="tap">THU MBNAILS - <?php print $whatupper; ?></td>
    </tr>
    </table>
    >
    <div align="center" class="gap5">&n bsp;</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">&n bsp;</div>
    >
    <?php
    >
    $batman=0;
    >
    $joker=opendir( $dir);
    while (false!==($boyw onder=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=subst r($demo,$riddle r-10,10);
    >
    $img_name="$dir " . "/" . "$demo";
    $thumb_name=str _replace($ext,$ thumbext,$img_n ame);
    >
    if ($penguin==$ext && $catwoman<>$thu mbext)
    {
    >
    $pass=1;
    $filename=$thum b_name;
    if (!file_exists($ filename)) {$pass=0;}
    >
    if ($pass==0)
    {
    $max_width=150; $max_height=80;
    $size=GetImageS ize($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=($si ze[0] / $ratio); $new_height=($s ize[1] / $ratio);
    if ($ext==".jpg") {$src_img=Image CreateFromJPEG( $img_name);}
    if ($ext==".gif") {$src_img=Image CreateFromGIF($ img_name);}
    if ($ext==".png") {$src_img=Image CreateFromPNG($ img_name);}
    $thumb=ImageCre ateTrueColor($n ew_width,$new_h eight);
    ImageCopyResamp led($thumb,$src _img,0,0,0,0,($ new_width-1),($new_height-
    1),$size[0],$size[1]);
    ImageJPEG($thum b,$thumb_name,1 00);
    ImageDestroy($s rc_img);
    ImageDestroy($t humb);
    >
    }
    }$temp=$temp+1;
    >
    }$homer=0;
    >
    $joker=opendir( $dir);
    while (false!==($boyw onder=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=subst r($demo,$riddle r-10,10);
    >
    if ($catwoman==$th umbext)
    {
    $thumb_name="$d ir" . "/" . "$demo";
    $img_name=str_r eplace($thumbex t,$ext,$thumb_n ame);
    $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<$colum ns)
    {
    >
    if ($loopy<$lisa)
    {
    >
    $passimage=1;
    $filename=$diam ondjoe[$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>DELET E THE FOLLOWING FILE</span>";
    print "<br>";
    print "<span class=nnb>$mill house[$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,$wiggu m-3);} else {$ralph="?";}
    $barney="$ralph " . "k";
    $apu=GetImageSi ze($diamondjoe[$loopy]);
    $size=GetImageS ize($millhouse[$loopy]);
    $duffbeer=$loop y+1;
    print "<td class=box>";
    print "<div align=left class=bar><span class=nna>($duf fbeer)</span>
    <span class=bba>$apu[0] x $apu[1]</span<span class=mma>$barn ey</span>
    </div>";
    print "";
    print "<div align=center class=gap3>&nbs p</div>";
    print "<a href=$diamondjo e[$loopy]><img src=$millhouse[$loopy] width=
    $size[0] height=$size[1] border=0></a><br>";
    print "</td>";
    >
    }
    }$tempxx=$tempx x+1;
    $loopy=$loopy+1 ;
    >
    }print "</tr>";
    >
    }print "</table>";
    >
    ?>
    >
    </body>
    </html>

    Comment

    • Krustov

      #3
      Re: Create thumbnails with clickable links XYZ

      <comp.lang.ph p>
      <hakan.magnusso n@gmail.com>
      <30 Oct 2006 06:58:33 -0800>
      <1162220312.874 847.142150@m7g2 000cwm.googlegr oups.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 :-)


      --

      Comment

      Working...