Site Navigation Code
  Home arrow Site Navigation Code arrow Simply image viewer script
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
SITE NAVIGATION CODE

Simply image viewer script
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 9
    2005-08-20

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    This script reads images in your dir and displays first one with next prev buttons. No work needed just drop in dir. Also gives thumbnail option and links at bottom to each image in the dir

    By : eltreno

    <?php

    //=========================================
    //
    // Author: Trent Williams
    // Date: 19 Aug 2005


    // EXPLAINATION
    //
    // A simply script to drop in any dir to display next prev buttons and current image for all your images in that dir with extentions you allow
    // Uses id parameter to know what image to show next else it will show first image
    // Also a number list at bottom page to go to any image, alt text displays image name

    // change the colours in the styles in the html body






    //which dir
    $d = dir(".");

    //read thru and
    while (false !== ($entry = $d->read())) {
    //allow extensions here
    //|| preg_match("/(\.bmp$)/i", $entry)
    //|| preg_match("/(\.jpeg$)/i", $entry)

    if (preg_match("/(\.gif$)/i", $entry) || preg_match("/(\.jpg$)/i", $entry)){
    $pics[] = $entry;
    }

    }
    $d->close();


    //================
    //total images count
    $numPics = count($pics);



    //================
    //picture in array to show on this page
    $thispic = 0;
    if (is_numeric($_GET['id'])){
    $thispic = $_GET['id'];
    }
    $thispicDisplay = $thispic + 1;



    //================
    //img tag for current image
    $thisImage = '<img src="' . $pics[$thispic] . '" alt="' . $pics[$thispic] . '" />';



    //======================
    // START set thumbnails on or off

    //comment this section out if you don't want thumbs to show at all

    $showThumbs = 5;//number of thums to show
    $thumbsList = '';
    $thumburl = '';
    if ($_GET['thumb'] == 'yes'){
    //read thumb param to url if exists
    $thumburl = '&amp;thumb=yes';

    for ($i=0;$i<$showThumbs;$i++){
    if ($thispic + $i + 1 < $numPics){
    $currThumb = $thispic + $i + 1;
    $thumbsList .= '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $currThumb . $thumburl . '" title="' . $pics[$currThumb] . '"><img src="' . $pics[$currThumb] . '" alt="' . $pics[$currThumb] . '" height="100" width="100" border="0" /></a>&nbsp;&nbsp;&nbsp;';
    }
    }
    $onOff ='<a class="thumbs" href="' . $_SERVER['PHP_SELF'] . '?id=' . $thispic . '">Turn Thumbnails Off</a>';
    } else {
    $onOff ='<a class="thumbs" href="' . $_SERVER['PHP_SELF'] . '?id=' . $thispic . '&amp;thumb=yes">Turn Thumbnails On</a>';
    }

    // END set thumbnails on or off





    //prev button

    $prevurl = ' <span class="highlighted">First Picture</span>';
    if ($thispic > 0){
    $prev = $thispic - 1;
    $prevurl = '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $prev . $thumburl . '" title="' . $pics[$prev] . '">Previous picture</a>';
    }




    //next button

    $nexturl = ' <span class="highlighted">Last Picture</span>';
    if ($thispic < ($numPics - 1)){
    $next = $thispic + 1;
    $nexturl = '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $next . $thumburl . '" title="' . $pics[$next] .'">Next picture</a>';
    }



    //=======================
    // string of all pics url's
    $urlarray = '';
    for ($i=0;$i<count($pics);$i++){
    //highlign pic you are on
    $j = $i + 1;

    if ($i != $thispic){

    $urlarray .= '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $i . $thumburl .'" title="' . $pics[$i] . '">' . $j .'</a> ';
    } else {
    $urlarray .= ' <span class="highlighted">' . $j . '</span> ';
    }


    }







    ?>
    <?php echo '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n"; ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title><?=$pics[$thispic]?></title>
    <meta name="Author" content="Trent Williams" />
    <style type="text/css">
    *{margin:0px;}
    html, body{color:#000; background-color:#000;}
    .borders {background:#DBDE5C; border:2px solid #DF1C11; padding:10px; width:100%; float:left; font-family:arial, helvetica, sans-serif; font-size:85%;}
    .content {padding:10;}
    a{color:#000;text-decoration:none; font-weight:bold;}
    a:hover{text-decoration:underline;}
    .highlighted {color:#DF1C11; font-weight:bold;}

    a.thumbs {color:#DBDE5C;text-decoration:none; font-weight:bold;}

    </style>
    </head>

    <body>


    <table cellpadding="0" cellspacing="10" border="0">
    <tr>
    <td>

    <div class="borders"><?=$prevurl?>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<?=$nexturl?>&nbsp;&nbsp;&nbsp;Picture number: <strong><?=$thispicDisplay?></strong> &nbsp;&nbsp;Picture name: <strong><?=$pics[$thispic]?></strong></div>




    <div class="content"><center><?=$thisImage?></center></div>

    <div class="content"><?=$onOff?><center><?=$thumbsList?></center></div>

    <div class="borders"><?=$urlarray?></div>


    </td>
    </tr>
    </table>


    </body>
    </html>
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Site Navigation Code Articles
    More By Codewalkers

     

    IBM® developerWorks developerWorks - FREE Tools!


    Check out the new Jazz space on developerWorks

    <a href="http://zeus.developershed.com/shonuff.php?blackbird=3853&zoneid=442&source=&dest=http%3A%2F%2Fwww.ibm.com%2Fdeveloperworks%2Fspaces%2Fjazz%3FS_TACT%3D105AGY31%26S_CMP%3DDEVSHED&ismap="><img src="http://images.devshed.com/corp/img/news/jazz01.gif" alt="developerWorks Jazz space" align="left"></a>You've heard the buzz about Jazz... want to know more about it from a developer's perspective? Check out the Jazz space on developerWorks. This space is an up-to-date resource for developers, including technical information about Jazz and products built on Jazz, like Rational Team Concert Express. The Jazz space includes content from a wide variety of sources, including links, feeds, and comments from experts.
    FREE! Go There Now!


    NEW! Driving Business Success with Rational Process Library

    Join this webcast, to learn how the Rational Process Library can help with compliance issues, drive process improvement, and assist in service-oriented architecture (SOA) or Agile development. We will take a peek into the Rational Process Library with content around software and systems engineering (including RUP), operations and systems management, program and portfolio management, and asset and SOA governance.
    FREE! Go There Now!


    NEW! Innovate don't duplicate! Asset reuse strategies for success

    Asset Reuse is a key strategy for companies looking to create innovative solutions to solve complex software development problems. Searching for, identifying, updating, using and deploying software assets can be a difficult challenge. Listen to this webcast, to learn about strategies and tools that you can leverage for a successful project, including Rational Asset Manager, Rational Software Architect and WebSphere Service Registry and Repository.
    FREE! Go There Now!


    NEW! Integrating XML into Your Enterprise Using Data Federation

    XML has become a common way of storing business data as flat files and many data server vendors including IBM have provided ways to store this data within relational database systems. Increasingly collections of XML files are accessed like databases using an xQuery and other XML standard mechanisms. Businesses find the need to combine the traditional tabular structured data with XML formatted data. In this webcast, you’ll learn about IBM’s WebSphere Federation Server technology, which provides users with the ability to integrate these two data formats.
    FREE! Go There Now!


    NEW! Rational Asset Manager eKit

    Learn how to do more with your reusable assets with the free Rational Asset Manager eKit. The eKit includes demos on how Rational Asset Manager tracks and audits your assets in order to utilize them for reuse. Plus you’ll find white papers and a Webcast that discuss the challenges of a Service Oriented Architecture and how Rational Asset Manager can provide quick and effective solutions.
    FREE! Go There Now!


    NEW! Rational Build Forge Express eKit

    Rational Build Forge Express Edition is an automation framework that packages the latest enterprise-grade technologies into a reliable, flexible and robust configuration designed and priced specifically for small to midsize businesses. The new Rational Build Forge Express eKit provides you with valuable resources – including a case study, podcast, demo, and articles – to help you increase staff productivity, compress development cycles and deliver better software, fast.
    FREE! Go There Now!


    NEW! Run your first CICS application on a PC using TXSeries for Windows

    Learn the basics of the IBM Customer Information Control System (CICS). With a hands-on exercise, learn how to get your first CICS application up and running on your desktop using TXSeries V6.1 for Windows. The tutorial shows you how to download and install a free trial version of TXSeries V6.1.
    FREE! Go There Now!


    NEW! Trial download: IBM Rational Tester for SOA Quality V7.0.1

    Get a free trial download of the latest version of IBM Rational Tester for SOA Quality V7.0.1, a functional and regression testing tool that enables the creation, comprehension, modification and execution of testing GUI-less Web services.
    FREE! Go There Now!


    NEW! Try the IBM SOA Sandbox for Process

    Visit IBM developerWorks to try the IBM SOA Sandbox for process. The SOA Sandbox for process focuses on providing a trial environment with the necessary tooling and components required to gain a better understanding of business processes and how to best improve existing business processes to derive value quickly.
    FREE! Go There Now!


    NEW! Webcast: What is new in Viper 2 for developers?

    Viper 2 brings a great value to developer communities including SQL, XML, PHP, Ruby, .NET and Java. You probably already know that DB2 Express-C is free for developers to develop, deploy and distribute. Viper 2 provides a variety of means that help move your application from the development stage to deployment more rapidly. This webcast shows how to best utilize the latest tools available for developing DB2 applications.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    SITE NAVIGATION CODE ARTICLES

    - Simple Menu System
    - Simply image viewer script
    - Simple File Lister
    - Dynamic Error Pages
    - BSoftEditor
    - Yahoo Status
    - Page numbers
    - PHP Search Navigator 1.0
    - Simple Page Navigation
    - An easy page browser ( prev 6 7 8 9 10 next )
    - AutoIndex PHP Script (Directory Indexer)
    - Bs_HtmlNavigation (Navigation and Sitemap cl...
    - Another Paging with Stage
    - Website Navigation via PHP
    - MySQL Paging Class





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    Stay green...Green IT