-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgallery.php
31 lines (27 loc) · 1.02 KB
/
gallery.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
class Gallery {
public $path; //this will be later set as a variable in index.php
public function setPath($path) {
$this->path = $path;
}
private function getDirectory($path) {
return scandir($path);
}
public function getImages($extensions = array()) {
$images = $this->getDirectory($this->path); //list all files
foreach($images as $index => $image) {
$explode = explode('.', $image);
$extension = end($explode);
if(!in_array($extension, $extensions)) { //check if files extensions meet the criteria set in index.php
unset($images[$index]);
} else {
$images[$index] = array( //make an array of images and corresponding miniatures
'full' => $this->path . '/' . $image,
'thumb' => $this->path . '/thumbs/' . $image
);
}
}
return (count($images)) ? $images : false;
}
}
?>