Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Read All Images from a folder And display slide show.
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script src="jquery.innerfade.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
$('#image_rotate').innerfade({
speed: 'slow',
timeout: 2000,
type: 'sequence',
containerheight: '220px'
});
});
</script>
<ul id="image_rotate" style="list-style: none;">
<?= $image_rotation; ?>
</ul>
<?
// Global Variables
$image_dir = "$_SERVER[DOCUMENT_ROOT]/bdexchange/assets/slide"; // directory on server
$image_relative_path = 'assets/slide'; // path to images relative to script
$file_types = array('jpg', 'jpeg', 'gif', 'png');
$image_time = '4000'; // seconds each image will display (4000 = 4 seconds)
$image_rotation ='';
if ($handle = opendir($image_dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$ext_bits = explode(".", $file); // finds file extensions
foreach ($ext_bits as $key => $value) {
if (in_array($value, $file_types)) {
$image_rotation .= '<li><img src="' .base_url().$image_relative_path . '/' . $file . '"></li>';
}
}
}
}
closedir($handle);
}
?>
http://medienfreunde.com/lab/innerfade/
http://medienfreunde.com/lab/innerfade/
@oklawaha

This comment has been minimized.

Show comment Hide comment
@oklawaha

oklawaha Apr 29, 2015

These scripts are very helpful, but I'm having trouble referencing the php from my html file. It only seems to work if I embed it in a php file.

These scripts are very helpful, but I'm having trouble referencing the php from my html file. It only seems to work if I embed it in a php file.

@JoffreCamacho

This comment has been minimized.

Show comment Hide comment
@JoffreCamacho

JoffreCamacho Dec 30, 2016

ty the plugin was very usefull indeed.

ty the plugin was very usefull indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment