corillo181 Posted April 21, 2006 Share Posted April 21, 2006 how come there is not one easy to follow gallery tutorial out there.. i been every where that googles throw me.. and only find scripts already made or tutorial made for advance ppl.how could i get advance if i don't know the basics of workin with pictures?every where i go is like no one cares about pictures.. dammit isn't anyone out there that knows how to deal with pictures or found a tutorial easy to follow?pleaseee if any ones know just let me know...please :|thank you.. Quote Link to comment https://forums.phpfreaks.com/topic/8073-solved-what-is-it-with-pictures/ Share on other sites More sharing options...
kenrbnsn Posted April 21, 2006 Share Posted April 21, 2006 What do you want to know?Ken Quote Link to comment https://forums.phpfreaks.com/topic/8073-solved-what-is-it-with-pictures/#findComment-29437 Share on other sites More sharing options...
corillo181 Posted April 21, 2006 Author Share Posted April 21, 2006 [!--quoteo(post=367301:date=Apr 21 2006, 04:30 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 21 2006, 04:30 PM) [snapback]367301[/snapback][/div][div class=\'quotemain\'][!--quotec--]What do you want to know?Ken[/quote]like i got this cript that i put in a index page and with subdirectories full of pictures and the scrip take the subs and make then i'm not galleries and when you click on one you see all the pictures inside..what i meanly want to do is how do i call for pictures.. because i don't understand this one bitdefine('PATH', str_replace('\\', '/', getcwd()));thats the patht hat look for all the pictures i guess i don't know :( Quote Link to comment https://forums.phpfreaks.com/topic/8073-solved-what-is-it-with-pictures/#findComment-29446 Share on other sites More sharing options...
eves Posted April 22, 2006 Share Posted April 22, 2006 [!--quoteo(post=367310:date=Apr 21 2006, 03:58 PM:name=Richard181)--][div class=\'quotetop\']QUOTE(Richard181 @ Apr 21 2006, 03:58 PM) [snapback]367310[/snapback][/div][div class=\'quotemain\'][!--quotec--]like i got this cript that i put in a index page and with subdirectories full of pictures and the scrip take the subs and make then i'm not galleries and when you click on one you see all the pictures inside..what i meanly want to do is how do i call for pictures.. because i don't understand this one bitdefine('PATH', str_replace('\\', '/', getcwd()));thats the patht hat look for all the pictures i guess i don't know :([/quote]getcwd() - get current working directory function, it just returns the path of the file and replace any forward slashes with backslashes and places the value in the defined variable PATH.eg: your file is located in say: "public_html/gallery/", this value is stored on the PATH variable and is used to display the images on other lines of code.My guess is placing the file to where your images are will solve the problem or just change the 2nd parameter of define() to the path of your images.Hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/8073-solved-what-is-it-with-pictures/#findComment-29597 Share on other sites More sharing options...
corillo181 Posted April 23, 2006 Author Share Posted April 23, 2006 ye sho does a little, but ll the ppl that knows about php has to say is that i needed to learn OOP.. it would of really make a big different and i been trying to find a easy tutoril no wonder why i never found one..i didn't know how to wokr with OOP.. Quote Link to comment https://forums.phpfreaks.com/topic/8073-solved-what-is-it-with-pictures/#findComment-29739 Share on other sites More sharing options...
kenrbnsn Posted April 23, 2006 Share Posted April 23, 2006 You don't [b]need[/b] to learn OOP.Ken Quote Link to comment https://forums.phpfreaks.com/topic/8073-solved-what-is-it-with-pictures/#findComment-29754 Share on other sites More sharing options...
corillo181 Posted April 23, 2006 Author Share Posted April 23, 2006 [!--quoteo(post=367623:date=Apr 23 2006, 01:50 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 23 2006, 01:50 AM) [snapback]367623[/snapback][/div][div class=\'quotemain\'][!--quotec--]You don't [b]need[/b] to learn OOP.Ken[/quote]well so i dont know hoe to deal with it with out learnign it, because in every tutorial about pictures they all use classes.. no one has taken the time to create a simply photo gallery with out the use of classes.. Quote Link to comment https://forums.phpfreaks.com/topic/8073-solved-what-is-it-with-pictures/#findComment-29876 Share on other sites More sharing options...
kenrbnsn Posted April 24, 2006 Share Posted April 24, 2006 Maybe you're looking in the wrong places?Here is my quick & dirty tutorial on picture galleries.Think about what you need for a gallery of pictures:[list][*]A directory to hold the images[*]A directory to hold the thumbnails (optional)[*]A database table to match up pictures with information about the pictures (optional)[*]A script to display the thumnails[*]A script to display a selected image (can be the same script as above)[/list]The simplest gallery has a directory to hold the thumbnails and a directory to hold the pictures with both the thumbnail images and the fullsize images having the same name. Let's call the thumbnail directory 'thumbs' and the image directory 'images'. Both reside one level down from the directory where the script is. There is no database involved.Below is the basic code needed to [ol type=\'1\'][*]Display the thumbnail pictures as links[*]Display a full size picture when a thumbnail is clicked.[/ol]I haven't included how to format the display in the code. I use CSS, but some people use tables.[code]<?phpif(isset($_GET['pic'])) { // When a thumbnail is clicked, the name of the image files will be passed on the URL by the variable "pic" if (file_exists('images/' . $_GET['pic'] . '.jpg') && basename($_GET['pic'],'.jpg') == $_GET['pic']) { // security check list($width, $height, $type, $attr) = getimagesize('images/' . $_GET['pic'] . '.jpg'); echo '<img src="images/' . $_GET['pic'] . '.jpg"' . ' ' . $attr . '><br>'; } echo 'Return to the <a href="' . $_SERVER['PHP_SELF'] . '">thumbnails</a>';}else { //display the thumbnails $tn = glob('thumbs/*.jpg'); if (is_array($tn)) foreach ($tn as $pic) { list($width, $height, $type, $attr) = getimagesize($pic); echo '<a href="' . $_SERVER['PHP_SELF'] . '?pic=' . basename($pic,'.jpg') . '"><img src="' . $pic . '" ' . $attr . '></a>'; }}?>[/code]A test script using this code can be run at [a href=\"http://www.rbnsn.com/phpfreaks/gallery/test_gallery.php\" target=\"_blank\"]http://www.rbnsn.com/phpfreaks/gallery/test_gallery.php[/a]Ken Quote Link to comment https://forums.phpfreaks.com/topic/8073-solved-what-is-it-with-pictures/#findComment-29980 Share on other sites More sharing options...
corillo181 Posted April 25, 2006 Author Share Posted April 25, 2006 hmmm it works but i want to learn how to do it on my own..i already know how to open the directory and read the file , but i don't know how to make iit display the picture Quote Link to comment https://forums.phpfreaks.com/topic/8073-solved-what-is-it-with-pictures/#findComment-30387 Share on other sites More sharing options...
kenrbnsn Posted April 25, 2006 Share Posted April 25, 2006 This is the code that reads the directory and displays each thumbnail as a link:[code]<?php//display the thumbnails $tn = glob('thumbs/*.jpg'); if (is_array($tn)) foreach ($tn as $pic) { list($width, $height, $type, $attr) = getimagesize($pic); echo '<a href="' . $_SERVER['PHP_SELF'] . '?pic=' . basename($pic,'.jpg') . '"><img src="' . $pic . '" ' . $attr . '></a>'; }?>[/code]BTW, the [a href=\"http://www.php.net/glob\" target=\"_blank\"]glob()[/a] function makes getting lists of files from directories very easy.Ken Quote Link to comment https://forums.phpfreaks.com/topic/8073-solved-what-is-it-with-pictures/#findComment-30388 Share on other sites More sharing options...
corillo181 Posted April 25, 2006 Author Share Posted April 25, 2006 yeah but what am saying is whats the code that display the pictures.. like readdir(0 reads the directory.. what code in simple terms reads the picture, becuase you got it up there with a few arrays and i just want the code alone.. Quote Link to comment https://forums.phpfreaks.com/topic/8073-solved-what-is-it-with-pictures/#findComment-30394 Share on other sites More sharing options...
kenrbnsn Posted April 25, 2006 Share Posted April 25, 2006 I can't seperate the code from the arrays since they are all tied together.I suggest you look at the PHP source, then show the generated pages. First show the generated code for the generated thumbnails. You should be able to see how the PHP is generating the HTML. The click on one of the thumbnails and look at the generated HTML of the displayed picture.Also, take the script, put iin on your own server, put some debugging statements in to dump the arrays so you can see how the arrays are being used.Ken Quote Link to comment https://forums.phpfreaks.com/topic/8073-solved-what-is-it-with-pictures/#findComment-30396 Share on other sites More sharing options...
corillo181 Posted April 25, 2006 Author Share Posted April 25, 2006 for future reference it was as easy as this...[code]<?$path ="/Gallery/thumbs/";$handle = opendir($path);while(false !==($file=readdir($handle))) { if($file !="." && $file !=".."){ echo"<img src=$path/$file>";}}closerdir($handle);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8073-solved-what-is-it-with-pictures/#findComment-30415 Share on other sites More sharing options...
kenrbnsn Posted April 25, 2006 Share Posted April 25, 2006 As I said before, the glob() function makes this even easier:[code]<?php$path ="/Gallery/thumbs/";$files = glob($path . '*.jpg');foreach($files as $file) { list($width, $height, $type, $attr) = getimagesize($file); // this function will put the "width=nnn height=nnn" into the variable $attr echo '<img src="' . $file . ' ' . $attr . '>'; // when ever you use the <img> tag you should specify the width and height} ?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/8073-solved-what-is-it-with-pictures/#findComment-30546 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.