LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-20-2010, 10:50 AM   #1
ziphem
Member
 
Registered: Feb 2004
Location: US / EU
Distribution: Fedora 31
Posts: 225

Rep: Reputation: 29
PHP dynamic file/image display: linking to full-sized thumbnails with diff. name, dir


I was hoping someone could give me some pointers on improving this code, and also making one part of it possible - I'm stumped!

I am able to display the thumbnail images in directory "driveway/thumbs/images_thumbs.jpg" dynamically but what I'd also like is to 'a href' to the main images in the parent directory (driveway/images.jpg). These images also have a different name (do not have _thumbs appended). I have been struggling for the last few days, and I just can't get this to work....

Images are uploaded to the main "driveway" directory, and every 20 minutes, they are converted to thumbnails. The thumbnails are put in to the driveway/thumbs directory, and the originals are put in the driveway/thumbs directory. I have inserted a provision in here for the 20 minutes between conversions. In any case, when I click on a thumb, of course I'd like to see the full sized original....and that's where the coding issues come in.

Any help is much appreciated, even with helping tighten my hodgepodge code!!!! Thank you!!!


Code:
<?php

$dirdriveway = "./driveway/thumbs/";
$dirdriveway_preprocessed = "./driveway/";
$dirden = "./den/thumbs";
$dirden_preprocessed = "./den/";
$fddriveway = opendir("$dirdriveway");
$fddriveway_preprocessed = opendir("$dirdriveway_preprocessed");
$fdden = opendir("$dirden");
$fdden_preprocessed = opendir("$dirden_preprocessed");

echo "<hr><hr><b><u><h2>DRIVEWAY</h2></u></b>";

while($entry = readdir($fddriveway)) {
if(eregi(".(exe|zip|jpg)$", $entry)) {
echo "<a href=\"$dirdriveway$entry\"><img src=\"$dirdriveway$entry\" border=\"0\" alt=\"$entry\">" .
"</a>\n";
}
}

closedir($fddriveway);

echo "<br><br><b>Pre-processed</b><br>";
while($entry = readdir($fddriveway_preprocessed)) {
if(eregi(".(exe|zip|jpg)$", $entry)) {
echo "<a href=\"$dirdriveway_preprocessed$entry\"><img src=\"$dirdriveway_preprocessed$entry\" border=\"0\" width=\"232\" height=\"158\" alt=\"$entry\">" .
"</a>\n";
}
}

closedir($fddriveway_preprocessed);


echo "<br><br><hr><hr><b><u><h2>DEN</h2></u></b>";
while($entryden = readdir($fdden)) {
if(eregi(".(exe|zip|jpg)$", $entryden)) {
echo "<a href=\"$dirden$entryden\"><img src=\"$dirden$entryden\" border=\"0\" alt=\"$entryden\">" .
"</a>\n";
}
}

echo "<br><br><b>Pre-processed</b><br>";
while($entry = readdir($fdden_preprocessed)) {
if(eregi(".(exe|zip|jpg)$", $entry)) {
echo "<a href=\"$dirden_preprocessed$entry\"><img src=\"$dirden_preprocessed$entry\" border=\"0\" width=\"232\" height=\"158\" alt=\"$entry\">" .
"</a>\n";
}
}

closedir($fdden_preprocessed);


closedir($fdden);
?>
 
Old 10-22-2010, 10:21 PM   #2
sleddog
Member
 
Registered: Jan 2002
Location: Labrador, Canada
Distribution: CentOS, Debian
Posts: 182

Rep: Reputation: 35
Quote:
Originally Posted by ziphem View Post
I am able to display the thumbnail images in directory "driveway/thumbs/images_thumbs.jpg" dynamically but what I'd also like is to 'a href' to the main images in the parent directory (driveway/images.jpg). These images also have a different name (do not have _thumbs appended).
Then you need to modify the image name before building the link.

If $entry holds "images_thumbs.jpg" then you can do a simple str_replace to get "images.jpg"...

Code:
// $entry is "images_thumbs.jpg"...
$fullsize = str_replace('_thumbs','',$entry);
echo "<a href=\"$dirdriveway_preprocessed$fullsize\"><img src=\"$dirdriveway_preprocessed$entry\" border=\"0\" width=\"232\" height=\"158\" alt=\"$fullsize\">" . "</a>\n";
 
Old 10-23-2010, 02:49 PM   #3
ziphem
Member
 
Registered: Feb 2004
Location: US / EU
Distribution: Fedora 31
Posts: 225

Original Poster
Rep: Reputation: 29
Omg. Awesomeness. I made the provided change, and tweaked the script overall a bit, and it's working great. Thank you!
 
Old 10-23-2010, 02:54 PM   #4
sleddog
Member
 
Registered: Jan 2002
Location: Labrador, Canada
Distribution: CentOS, Debian
Posts: 182

Rep: Reputation: 35
Great! Glad to hear you worked it out.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Static linking vs. dynamic linking? posix_memalign Programming 13 04-18-2010 02:27 PM
SCP a file to diff directory/change filename using PHP or call sh script fm PHP nuebelhor Red Hat 1 11-05-2009 08:03 AM
linking the kernel and the ramdisk to a single image file. KitKat08 Red Hat 1 02-09-2006 08:59 AM
making konquerer display image thumbnails large, but other icons small? webazoid Linux - Software 0 08-01-2004 08:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration