private function LocalFolderProvider::getImages in Devel images provider 8
Same name and namespace in other branches
- 7 plugins/devel_image_provider/provider/LocalFolderProvider.class.php \LocalFolderProvider::getImages()
Helper function to get all the images from the configured folder.
1 call to LocalFolderProvider::getImages()
- LocalFolderProvider::generateImage in plugins/
devel_image_provider/ provider/ LocalFolderProvider.class.php - Image generation handler.
File
- plugins/
devel_image_provider/ provider/ LocalFolderProvider.class.php, line 97 - Local folder support class.
Class
- LocalFolderProvider
- Add support for local images.
Code
private function getImages() {
$files = array();
$count = 1;
// Limiting number of images to find to 100.
// @TODO: add this as a setting.
$max_count = 100;
// Remove trailing slash.
$dir = rtrim($this->settings['devel_image_provider_path'], '/');
if (is_dir($dir) && ($handle = opendir($dir))) {
while (FALSE !== ($filename = readdir($handle)) && $count <= $max_count) {
$path = "{$dir}/{$filename}";
if ($filename[0] != '.' && preg_match('/.*\\.(jpg|jpeg|png)$/i', $filename) && FALSE !== image_get_info($path)) {
$file = new stdClass();
$file->uri = file_stream_wrapper_uri_normalize($path);
$file->filename = $filename;
$file->name = pathinfo($filename, PATHINFO_FILENAME);
$files[$file->uri] = $file;
$count++;
}
}
closedir($handle);
}
return $files;
}