TheDutchBeast Posted January 10, 2013 Share Posted January 10, 2013 Hello follow programmers, I have a little question regarding my PHP code. I now have a perfect working code that takes my frame heigth and width and adjusts the image to the frame. Works great. The issue now is, I have multiple images in my dolder, how can I play them with a delay of say.. 10 seconds? Here is the piecer of my code that matters: Of course I have to count the images in the folder but how do I play them with a short break in it. <?php $img_folder = "../fotos/"; $imgs = dir($img_folder); while ($file = $imgs->read()) { $lengte = (strlen($file)-3); $extentie = substr($file,$lengte,3); //print "extentie $lengte = $extentie <br>"; if($extentie == "jpg" || $extentie == "JPG" || $extentie =="jpeg" || $extentie =="gif" || $extentie =="bmp"){ //print "tada<br>"; $size = getimagesize($img_folder.$file); $hoog = $size[1]; $breed = $size[0]; if(($breed/$screenW)>($hoog/$screenH)){ print"<img src=\"$img_folder$file\" width=\"$screenW\">"; }else{ print"<img src=\"$img_folder$file\" height=\"$screenH\">"; } } } closedir($imgs->handle); } ?> Thanks in advance! Dave Link to comment https://forums.phpfreaks.com/topic/272952-playing-all-images-from-folder-with-pause-in-between/ Share on other sites More sharing options...
cpd Posted January 10, 2013 Share Posted January 10, 2013 Once PHP has processed your script server-side the web server sends the content to the client. Once that's happened you can't edit the content of the page with just PHP without sending another request. You'll need to use Javascript to cycle through the images. Link to comment https://forums.phpfreaks.com/topic/272952-playing-all-images-from-folder-with-pause-in-between/#findComment-1404746 Share on other sites More sharing options...
TheDutchBeast Posted January 11, 2013 Author Share Posted January 11, 2013 You have any idea how I can do that? So its not possible with php? Link to comment https://forums.phpfreaks.com/topic/272952-playing-all-images-from-folder-with-pause-in-between/#findComment-1404881 Share on other sites More sharing options...
cpd Posted January 11, 2013 Share Posted January 11, 2013 PHP is a server-side language not a client-side language, so no its not possible to carry out the cycling of images through PHP. Link to comment https://forums.phpfreaks.com/topic/272952-playing-all-images-from-folder-with-pause-in-between/#findComment-1404883 Share on other sites More sharing options...
TheDutchBeast Posted January 11, 2013 Author Share Posted January 11, 2013 I understand that. Do you have a javascript solution, or is this not the place to be for that? Link to comment https://forums.phpfreaks.com/topic/272952-playing-all-images-from-folder-with-pause-in-between/#findComment-1404900 Share on other sites More sharing options...
cpd Posted January 11, 2013 Share Posted January 11, 2013 Google should give you a nice solution. There is a jQuery "Cycle" plugin found at http://jquery.malsup.com/cycle/ which you could use. There are loads available, find one that suits you and implement it A Mod may move the topic to Javascript help. Link to comment https://forums.phpfreaks.com/topic/272952-playing-all-images-from-folder-with-pause-in-between/#findComment-1404904 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.