|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Article Discussion: Creating An Online Photo Album with PHP and GD: Part 4
If you have any questions or comments on this article then please post them here.
This forum post relates to this article |
|
#2
|
|||
|
|||
|
REMOVED
|
|
#3
|
|||
|
|||
|
iahmed,
I'm sorry you feel that way... I wanted to write the article to address all levels of PHP knowledge, not just an advanced user. Had I written it in an advanced context, I'm sure I could have completed it in a single article as well. The fact that I introduced a class and OO concepts demanded more "introductory" explanations... Also, GD can be a complicated topic for beginners, so I felt that the article warranted detailed explanation. I do appreciate the feedback, however... It has given me an idea on how to write my future article. Thanks again!
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
|
#4
|
|||
|
|||
|
Bugs
Frank,
Does this work on your server? It doesn't work on mine. In GallerySizer.php the copyImage and copyResize methods don't work. I had to replace copyImage with: PHP Code:
I had to replace copyResize with: PHP Code:
I don't know the need for the "copy" function since the "imagejpeg" function creates the image in the images and thumbs folders. The chmod function always produced errors. I didn't need the unlink functions except for the one that deletes the orginal. There are several other bugs that are causing me trouble as well. Right now I'm going to have to figure out the edit_photos.php page. It is not displaying the images correctly. Nice set of articles, except for the buggy code. I think I can figure it out, but I think the amount of bugs will make this a frustrating waste of time for someone who is not that experienced with php. |
|
#5
|
|||
|
|||
|
eqjones,
It's very odd that you're having problems with the edit_photos.php page. Do you have a live version up that I can take a look at? As for the copy() function, I was finding that after the imagejpeg() function was creating the resized/thumbnailed copies, it was storing those new images in the "temp" folder. By using the copy() function, it would copy them to the photos/thumbs folders. If you have any other problems, please let me know... Attention For all those who were waiting, the support file has now been updated to include the "fully tested code" |
|
#6
|
|||
|
|||
|
To Frank,
Thanks for the quick response. I downloaded the code either yesterday or the day before yesterday. Is there updated code now? I noticed in the gallery when looking at the pictures, the display_album.php page, the date was always showing up as the 1st, even when I didn't upload the pictures on the first. I traced the problem back to the "format_date" function in the config.php file. The date is split by "-" which leaves the $day holding a value like "11 21:55:55". So this is split by the space using: PHP Code:
However that creates a nested array that looks like: Code:
Array
(
[0] => Array
(
[0] => 11
[1] => 21:56:03
)
)
As a result a valid day value wasn't given to the "mktime" function. To fix this I rewrote the line to PHP Code:
|
|
#7
|
|||
|
|||
|
eqjones,
The code is now updated... To make sure you have the updated copy, there should be a "filler.gif" file located in the include directory. As for the date bug, that's weird... I had no problems on my system here. Althought it shouldn't make a difference, what OS are you running? I'll have to look into it... |
|
#8
|
|||
|
|||
|
To Frank,
It's great that you are replying to this forum. I appreciate your time to do that and to write the article. I had been working on a image uploading thing like you wrote about before your article. It was no where near as classy as yours and your use of the classes really helps me understand more how classes work into the whole scheme of things. I am using a shared server using a reseller accoung that uses Cpanel and WebHostManager. It has the Redhat Linux, PHP, and mySQL on it. The problem that I was having with the pictures not getting copied might have something to do with the server being a shared one. When I uploaded the pictures they went to the "photos" folder, not the "temp" folder. I didn't even see a "temp" folder. I don't know a lot about setting up linux, php, mysql servers and I have never had a dedicated server, so I'm thinking that it may have something to do with me using a shared server. The changes I mentioned seem to work fine for me. I downloaded the new code the day I posted my last post. It was updated from the first copy I downloaded. I'm not sure if you've updated it more recently though. I still had some bugs with it. The problem was, the Title and Description for the last picture of the upload list would overwrite all the other Titles and Descriptions in the SQL query. For example if I uploaded 4 pictures and set Pic4's title="Picture Four" and Pic4's Description="Picture Four Description", then the three other pictures would also be titled and described with Pic4's values. Easy fix, which you might have alread done: in image_upload.php, in the part where the values in the form is set, change this: PHP Code:
to: PHP Code:
The problem was the "photo_desc" and "photo_title" variables have to be different for each picture otherwise the values will overwrite each other. By inserting "$i+1" we insure each photo get's it's own variable...ie.. "photo_desc1", "photo_desc2", etc. We also have to change the SQL statement that adds the photo's entries to the database. So in create_thumbnails.php we want to change: PHP Code:
to: PHP Code:
All we are doing here is concatonating (sp?) "photo_desc" and "photo_title" with the counter "$i" that is being used in that file. We will also have to pass the "$i" variable to the function, so that'll have to be added to the function call and the function title (? I guess that's the correct terminology). Works like a charm ![]() Thanks again for the responses and article. I look forward to playing more with this as I have time. |
|
#9
|
|||
|
|||
|
I was also having a problem with the "edit_photos.php" file. It wanted to display all the pictures, but use the album cover image as the thumbnail, instead of the image's actual thumbnail image.
I think it would have been a lot better if you had made the edit_photos.php file like the gallery view files. You know, first you select the album, and then it gives you the images. I didn't rewrite it to do that, don't have the time right now. But I did, fix the bug. The problem is that in the last elseif group, the img src is putting the value of the album cover instead of the value of the thumbnail. Also, the SQL statement doesn't fetch the value for the thumbnail. So I changed: PHP Code:
to: PHP Code:
and I changed: PHP Code:
to: PHP Code:
|
|
#10
|
|||
|
|||
|
eqjones,
That may have something to do with it... When I tested it out on my server, it was here at home, so that may be the reason why they were being copied to the temp folder. As for the changes you've made, I'm glad you've been able to make them. It shows you're level of knowledge. It's weird that I didn't run into these problems myself. I'm gonna look into it here on my end, and see if I encounter the same problems you have. If you have it online, I'd like to see how you've employed the gallery. If you have any other questions, don't hesitate to post them! |
|
#11
|
|||
|
|||
|
Hello,
Thanks for the article Frank. It shows a clear way of how it's possible to create an Image Gallery. As said before.. maybe the article is a bit long. But of course , better too long than too short. The only thing that disappoints me in general in all articles.. is the yellow background when there's PHP code. It really makes it hard(er) to read and understand the code. It makes a huge difference when you see the code with neat highlighting. If syntax highlighting isn't possible for technical reasons.. then I prefer no background at all. Besides that, this is a great site with lot's of info. About the article itself. I haven't used it so I'm not aware of bugs. I only read it. What I found really good is the example of how to use classes in this project. There's a lot to read about OOP, but mostly it's a theory approach. This article helps me understand how to integrate a class in a project. I'm working on an Image Gallery myself. But I'm still having doubts about where the destination path of images should go. Maybe, $root.'/thumbs/'.$gallery_id.'/'.$thumb_img and $root.'/images/'.$gallery_id.'/'.$full_img is an option. Another directory layout could be: $gallery_id.'/thumbs/'.$thumb_img $gallery_id.'/images/'.$full_img Are there any special pro's and con's I'm not aware of? Or is it just a matter of how you personally prefer it? Another thing I found interesting is the use of two tables, and use a 'key' to link the id's. A very usefull method to create forums too, where their can be a table for topics and replies. Thanks again to share your knowledge and your time to write the article. -sven |
|
#12
|
|||
|
|||
|
Not sure exactly what you are trying to do, but I didn't like the thumbnails and resized full images having the same name. So I just added a "_tn" to the name of the thumbnails. I was happy with the photos table. It was a ton better than what I had done one my own before I read the article.
When it comes to the yellow print, I'm ok with that too. However, I do choose the "print" option and copy and past into a MS Word document. I then shrink the font, do some more editing to shrink the size so I have less pages and print it out. I can work and learn much better with the print copy, and I can take it with me and study it away from my computer. I have found possibly a bug in the resizing file. Not sure if it's something I've done though, but I don't think I've messed with that part of your code. I haven't gone through the resizing file checking how it was done yet to see if I can figure out what's happening. I'm going to work on templates and CSS first (again). But I uploaded a picture that was more tall than wide and it stretched the picture. It made it more squarish. Frank, if you want a link, I'll email it to you, but don't want to post it since I haven't put my sessions stuff in the upload files. Of course not asking you to trouble shoot my code. |
|
#13
|
|||
|
|||
|
I also wanted to add that I agree with Sven. You did a great job utilizing the classes in this tutorial. I found using classes much more difficult than GD. I've only taken freshman level Comp Sci classes back when C++ was being used and things were written more proceduraly than OOP. I have some trouble figuring out OOP.
I think you could write a great article on OOP and classes in PHP. Would be cool if you could write a tutorial on using OOP in a template system. Leave out the caching bit, that makes it much more complicated. Would be great for me, lol. I'm trying to figure out how I can use classes and use templates. I guess with classes, if code is often rewriten (copy and pasted) in files then I can use a class to keep from having to rewrite it. I want to set up a header, left side, center, right side, and footer. Most of the time the center will only be what's different. The rest is rewritten. But anyways, I think you'd do a great job writing an article like that. |