public static function getThumbnailFolders($path, $includeSource = false)
{
$return = array();
$filesystem = new Filesystem();
if (!$filesystem->exists($path)) {
return $return;
}
$finder = new Finder();
$finder->name('/^([0-9]*)x([0-9]*)$/');
if ($includeSource) {
$finder->name('source');
}
foreach ($finder->directories()->in($path)->depth('== 0') as $directory) {
$chunks = explode('x', $directory->getBasename(), 2);
if (count($chunks) != 2 && !$includeSource) {
continue;
}
$item = array();
$item['dirname'] = $directory->getBasename();
$item['path'] = $directory->getRealPath();
if (mb_substr($path, 0, mb_strlen(PATH_WWW)) == PATH_WWW) {
$item['url'] = mb_substr($path, mb_strlen(PATH_WWW));
}
if ($item['dirname'] == 'source') {
$item['width'] = null;
$item['height'] = null;
} else {
$item['width'] = $chunks[0] != '' ? (int) $chunks[0] : null;
$item['height'] = $chunks[1] != '' ? (int) $chunks[1] : null;
}
$return[] = $item;
}
return $return;
}