Hello Everyone
I need Help I have a Gallery And I want to Add Button lead more
I need Limit Number Of Images per Page
I have Images In Directory ,
The Index.php File :
<?php
require'gallery.php';
$gallery = new Gallery();
$gallery->setPath('gallery');
$images = $gallery->getImages();
?>
<!DOCTYPE html>
<html>
<head>
<title>Image Gallery</title>
<link rel="stylesheet" type="text/css" href="css/gallery.css">
</head>
<body>
<div class="Container">
<?php if($images): ?>
<div class="gallery cf">
<?php foreach($images as $image): ?>
<div class="gallery-item">
<img src="<?php echo $image['full']; ?>">
</div>
<?php endforeach; ?>
</div>
<?php else: ?>
there Are No images.
<?php endif ?>
<span id="loadmore" num_loaded="10">Load More</span>
</div>
</body>
</html>
the Gallery File :
<?php
class Gallery{
public $path;
public function __construct() {
$this->path = __DIR__ .'/gallery';
}
public function setPath($path){
if(substr($path, -1) == '/'){
$path=substr($path,0,-1);
}
$this->path = $path;
}
private function getDirectory($path){
return scandir($path);
}
public function getImages($extensions = array('jpg','png','gif')){
$images = $this->getDirectory($this->path);
foreach ($images as $index => $image) {
$extension =strtolower(end(explode('.', $image)));
if(!in_array($extension, $extensions)){
unset($images[$index]);
}else{
$images[$index] = array(
"full" => $this->path .'/'.$image,
"thumb"=> $this->path .'/thumbs/'.$image
);
}
}
return (count($images)) ? $images : false;
}
}
?>
please Help me