Jump to content

Playing all images from folder, with pause in between


TheDutchBeast

Recommended Posts

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

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.