public static function getList($folderPath, $thumbPath = null) {

    if (empty($thumbPath)) {
      $thumbPath = $folderPath;
    }

    // Array of image objects to return.
    $response = array();

    $absoluteFolderPath = $_SERVER['DOCUMENT_ROOT'] . $folderPath;

    // Image types.
    $image_types = Image::$defaultUploadOptions['validation']['allowedMimeTypes'];

    // Filenames in the uploads folder.
    $fnames = scandir($absoluteFolderPath);

    // Check if folder exists.
    if ($fnames) {
      // Go through all the filenames in the folder.
      foreach ($fnames as $name) {
        // Filename must not be a folder.
        if (!is_dir($name)) {
          // Check if file is an image.

          if (in_array(mime_content_type($absoluteFolderPath . $name), $image_types)) {
            // Build the image.
            $img = new \StdClass;
            $img->url = $folderPath . $name;
            $img->thumb = $thumbPath . $name;
            $img->name = $name;

            // Add to the array of image.
            array_push($response, $img);
          }
        }
      }
    }

    // Folder does not exist, respond with a JSON to throw error.
    else {
      throw new Exception('Images folder does not exist!');
    }

    return $response;
  }
public static function getList($folderPath, $thumbPath = null) {

    if (empty($thumbPath)) {
      $thumbPath = $folderPath;
    }

    // Array of image objects to return.
    $response = array();

    $absoluteFolderPath = $_SERVER['DOCUMENT_ROOT'] . $folderPath;

    // Image types.
    $image_types = Image::$defaultUploadOptions['validation']['allowedMimeTypes'];

    // Filenames in the uploads folder.
    $fnames = scandir($absoluteFolderPath);

    // Check if folder exists.
    if ($fnames) {
      // Go through all the filenames in the folder.
      foreach ($fnames as $name) {
        // Filename must not be a folder.
        if (!is_dir($name)) {
          // Check if file is an image.

          if (in_array(mime_content_type($absoluteFolderPath . $name), $image_types)) {
            // Build the image.
            $img = new \StdClass;
            $img->url = $folderPath . $name;
            $img->thumb = $thumbPath . $name;
            $img->name = $name;

            // Add to the array of image.
            array_push($response, $img);
          }
        }
      }
    }

    // Folder does not exist, respond with a JSON to throw error.
    else {
      throw new Exception('Images folder does not exist!');
    }

    return $response;
  }
public static function getList ( $ folderPath , $ thumbPath = null ) { if ( empty ( $ thumbPath ) ) { $ thumbPath = $ folderPath ; } // Array of image objects to return. $ response = array ( ) ; $ absoluteFolderPath = $ _SERVER [ 'DOCUMENT_ROOT' ] . $ folderPath ; // Image types. $ image_types = Image :: $ defaultUploadOptions [ 'validation' ] [ 'allowedMimeTypes' ] ; // Filenames in the uploads folder. $ fnames = scandir ( $ absoluteFolderPath ) ; // Check if folder exists. if ( $ fnames ) { // Go through all the filenames in the folder. foreach ( $ fnames as $ name ) { // Filename must not be a folder. if ( ! is_dir ( $ name ) ) { // Check if file is an image. if ( in_array ( mime_content_type ( $ absoluteFolderPath . $ name ) , $ image_types ) ) { // Build the image. $ img = new \ StdClass ; $ img -> url = $ folderPath . $ name ; $ img -> thumb = $ thumbPath . $ name ; $ img -> name = $ name ; // Add to the array of image. array_push ( $ response , $ img ) ; } } } } // Folder does not exist, respond with a JSON to throw error. else { throw new Exception ( 'Images folder does not exist!' ) ; } return $ response ; }
List images from disk

@param folderPath string

@return array of image properties
- on success : [{url: 'url', thumb: 'thumb', name: 'name'}, ...]
- on error   : {error: 'error message'}
List images from disk