Elgg  Version 4.3
LocalImage.php
Go to the documentation of this file.
1 <?php
2 
4 
6 
10 class LocalImage extends Image {
11 
15  public static function image($dir = null, $width = 640, $height = 480, $category = null, $fullPath = true, $randomize = true, $word = null, $gray = false) {
16  $local_folder = elgg_get_config('seeder_local_image_folder');
17  if (empty($local_folder) || !is_dir($local_folder)) {
18  return parent::image($dir, $width, $height, $category, $fullPath, $randomize, $word);
19  }
20 
21  $files = [];
22 
23  // read files in folder
24  $dir = new \DirectoryIterator($local_folder);
25  /* @var $file \SplFileInfo */
26  foreach ($dir as $file) {
27  if (!$file->isFile()) {
28  continue;
29  }
30 
31  $files[] = $file->getRealPath();
32  }
33 
34  if (empty($files)) {
35  return parent::image($dir, $width, $height, $category, $fullPath, $randomize, $word);
36  }
37 
38  // return random file
39  $key = array_rand($files);
40 
41  return $files[$key];
42  }
43 }
Provide images from a local folder for seeding.
Definition: LocalImage.php:10
static image($dir=null, $width=640, $height=480, $category=null, $fullPath=true, $randomize=true, $word=null, $gray=false)
{}
Definition: LocalImage.php:15
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:44
elgg_get_config($name, $default=null)
Get an Elgg configuration value.