Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: photo slideshow

  1. #1
    Join Date
    Apr 2008
    Posts
    21

    Unanswered: photo slideshow

    hello,

    i was wondering what would be the best way to store photos that you want to delete very easily and access very easily when making a photo slideshow with javascript, should i store the photos with mysql or what other way? also how would i set it up to have the database track how many times a photo has been viewed?
    Last edited by bardell38; 05-05-08 at 04:31.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    store the photos as a URL to the image, leave the photo outside the DB.
    as to how you store the number of times an image has been used thats up to you. you could have a sideshow list stored ie list one contents image 10,5,3,100 etc..., you could also store details of how the transitions should be handled, how long each image should be displayed and so on.. thats fairly trivial you may need say a SlideList entity, and a slidelistcontents entity.

    depeding on the application you could 'get' away with choosing some images at random from the URLS in the MySQL db.

    one drawback of storing only the URL is that its wuite possible that the image may get deleted or edited either inadvertantly or deliberately or maliciously. so thats something you need to keep in mind. you don't want you images being replaced or deleted at best it will make the user worry about the integrity of your site, at worst it may make them leave for ever.

    the jury is out on where to store images, some prefer in a db, some prefer outsdie the DB.. I prefer outside the DB
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Apr 2008
    Posts
    21
    are there any drawbacks for keeping the photo in the database and having one table for all?

    lets just say that i wanted to have an upload form for the photos so i don't have to do anything manual and right when a file gets uploaded it automatically becomes part of the slideshow and will be shown as soon as its uploaded (because of the large number of photos ill be having for my fraternity). what would be the best way to do this?

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    aside from bloating the db, increasing backup times,
    possible increased costs from the ISP,
    increased load times (as the application cannot take advantage of cached copies of the image (cached locally or inbetween the client and the db)
    increased traffic on the database server as every image has to come frotm eh single source, rather that multiple sources
    all images have to be "owned" by the db, its harder to refer to external images, say you foudn some image you wanted to use but the image owner refused you a copy, you have to refer to their image library

    there is no hard and fast rule on where to store the image.. its personal choice, as to where and how you store images. each solution has advantages and drawbacks, its up to you to strike a balance that is sutiable for yuour use.
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Apr 2008
    Posts
    21
    which do you think is faster for the slideshow?

  6. #6
    Join Date
    May 2008
    Posts
    9
    I think that storing the images in DB is faster on the short term, but once your db gets bigger and has alot of images in it, It will be only a matter of time before your host contacts you telling you that your causing too much load on the sql server !, because storing binary data in a db isnt that much of a good idea for large db's, actually its not even for small/normal sized db's since that everytime you add a file, your adding that file's size to the db ( actually a little bit more ).

    the bottom line, use the file system to store your images, store the URLs in the db and find a way to make a dynamic link to the images so you can deal with the download counter thingy meaning that the dynamic link fetches the real url from the db and increment the download counter by 1, so simple huh?

  7. #7
    Join Date
    Apr 2008
    Posts
    21
    yea yo i think that you said thingy like 20 times lol. ight so you think that i should store the images in a separate folder, then the real URL for the image you store in the database with the counter number of how many times that it has been viewed but how could you get the link to tell if its the photo or not you know what i'm saying? how can a url be passed so that it can tell whether its the image or not?

  8. #8
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    I go with healdem - you should just store the url in the database and store the image files as files in a directory. There was a long discussion on this a while back.

  9. #9
    Join Date
    May 2008
    Posts
    9
    bardell, didnt get how did I say "thingy" 20 times though , anywayz as an answer for ur question, I dont see why a URL should have to verify that the image thats its pointing to is the same image that its pointing to
    I mean... What else can it be ??

    BTW, I should mention that ur script should rename a file when it gets uploaded so you dont face a problem with files that has the same name&extension. use an md5 hash for the rename process or any similar method.


  10. #10
    Join Date
    Apr 2008
    Posts
    21
    okay so let me just go through a run through to make sure i understand.

    i have the javascipt slideshow code and everything, i have an upload form and everything. so i upload a picture named giantsdbforum.jpg. it submits to a temporary folder named like folder. then, i would have to have a php script to store the location of the file in the database and the number of views but befroe it is stored to teh database i change the name to image1234 or whatever number it is. then i have a php script to recognize that once it hits the certain number of views, it deletes itself from the database?

  11. #11
    Join Date
    Apr 2008
    Posts
    21
    but what im trying to say is that lets just say that you visit my page and is watching the slideshow. i upload a new photo on that slideshow during the same time you are viewing it, is there any way that the photo i added can be part of the slideshow without the user having to refresh the page? and how can i track how many times an image has been viewed in a slideshow? when i delete an image and its id was one, how can i make it in the database so that id number 2 becomes 1?

  12. #12
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so you are refreshing a picture control using Javascript

    in my books you have two options, either you add one to the images used list when you write the javascript (or however you are telling the browser which pictures to use), or you use an AJAX call to update the DB each time each picture is actually displayed on the browser.

    the former is more efficient (uses less resources does less work on the server and network.. but only reflects what image list the browser was instructed to display, not what was actually shown), the latter is more accurate (as it will update the counter when the page is viewed).

    mind you if you pull the images one at a time from the db using AJAX that will also immediately reflect any changes in your image list.
    I'd rather be riding on the Tiger 800 or the Norton

  13. #13
    Join Date
    May 2008
    Posts
    9
    Bardell, why mixing everything between PHP and javascript? why not try to do it in one of them? I personally prefer PHP at all times but there are a few things that javascript either do better or cannot be done by PHP, dont ask me what they are tho .
    Anywayz what im tryin to say here is that you should upload the image to a temporary folder, rename it using PHP since its doable by it, and then move it to the images folder. Now you store the URL in the db and start counting views.
    Once it hit a certain amount of view, PHP marks it as expired, then you have a cron job php script that runs every other day or something to delete all the marked-expired images ( lighter on the server )
    Try to decrease the use of Javascript since its heavier to load on the user's machine and dont work when a user disables it !
    As for your other question, I cant see why a user should happen to be browsing that slideshow at the same time ur uploading images and have the need to get the new images without refreshing the page, even YAHOO doesnt make a user that comfortable . anyways AJAX is the most recommended choice tho.
    As for the last question regarding the image id, there are some ways to do what u want, ways that involve unnecessary queries for the mysqlserver. I would just leave the id's as they are, after all they will still be unique thats what matters, right?

    Dont u run outta questions dude? /kidding

  14. #14
    Join Date
    Apr 2008
    Posts
    21
    okay thats sounds like a really good idea now how would u get the images in the image folder to be displayed in the slideshow. how would you even make the slideshow? javascript? i recognized at the beginning that you should preload all the images before you make the slideshow so that it would make a better transition but since u said that javascript takes too long to load how can u make it so that its just like a continuing slideshow with transitions like every 5 seconds?

  15. #15
    Join Date
    Apr 2008
    Posts
    21
    lol yea i got a lot of questions. this stuff can get really confusing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •