Hi! I'm wondering if somebody here could help me please. I'm trying to develope the image slideshow using PHP and JavaScript. The idea is that the PHP file gets random images from the folder, i'm using session to prevent repeating the same image and then JavaScript generates the fade slideshow using that PHP file. I've come up with the solution to use two img tags in the HTML page, so JavaScript then swap them around and play with opacity, but unfortunately couldn't make it work. Everything I have tried in JavaScript didn't work properly. I'd be grateful for any help and advice guys. Thank you.
function outputImage() { if (($file = $this->getNextImage()) !== false) { header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1 header('Expires: Wed, 9 Dec 1981 07:00:00 GMT'); // Date in the past header('Content-type: image/jpg'); readfile($this->imgDir.$file); exit(); } } } $img = new images(); $img->outputImage(); ?>
I would suggest combining your html and PHP and then preload all your images with JavaScript. Though you seem to be on the right track. Do you know what errors are being reported by the browser because those would be a helpful thing to have while debugging this.
I would suggest getting rid of the 'loaded' array unless it is doing something, but I'm not really see where it does anything useful.
Hi ninnypants! Thanks for your reply. Could you explain please what did you mean by saying combining PHP & HTML. It's already combined, because the src of the img tags calls this PHP file every time I refresh the page. I have no problems with PHP and HTML, it's JavaScript I cannot make it work properly to generate the fade gallery using those two html img tags and swapping them around. Thanks.
Hi vwphillips! Thank you for your reply. It works with the static images, but I'm still not sure how can link my PHP file to it, which dynamicly gets any images from the folder. In the example you've provided the images in the html bit are different, but in my case they are both the same because PHP gets only one image at the time. That's why one of them has got always opacity=0. Then javascript should basically swap them and fade one into another somehow, which I don't know how yet....
my post demonstrates that the Javascript works
Using clent side only the image src's would be registed in an array and the image srcs changed onload of the page usining random methods
the problem is how to set the src(or array) of the images using php
Unlike some other galleries, there is no need to create menu items or any other elements, just type the name of the folder containing images and that's it, it will show up all images from this folder, one by one. Also after that you may type file names separated with comma, to show exact images of selected folder and/or in exact order.
Slide show Interval and fade effect can be adjusted with three parameters: interval, fade time and fade step in milliseconds.