Elgg  Version 2.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) {
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
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
if(!array_key_exists($filename, $text_files)) $file
$key
Definition: summary.php:34
elgg image block elgg image
Definition: admin.css.php:433
static image($dir=null, $width=640, $height=480, $category=null, $fullPath=true, $randomize=true, $word=null)
{}
Definition: LocalImage.php:15
foreach($resources as $id=> $href) if(!empty($resources_html)) $files
Definition: details.php:141
http free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:5