function _user_badges_images_from_library in User Badges 7.2
Same name and namespace in other branches
- 7 user_badges.admin.inc \_user_badges_images_from_library()
- 7.3 user_badges.admin.inc \_user_badges_images_from_library()
Scan the badges image directory.
Return value
An array of images from the image library, in the form $filepath => object('image' => $image_html, 'file' => $file_unmanaged)
2 calls to _user_badges_images_from_library()
- user_badges_edit_form in ./
user_badges.admin.inc - Define the edit form for userbadges.
- user_badges_images_form in ./
user_badges.admin.inc - Form to upload the badge images or to delete existing ones.
File
- ./
user_badges.admin.inc, line 875 - @brief User Badges admin functions
Code
function _user_badges_images_from_library() {
$selects = array();
$path = 'public://badges';
file_prepare_directory($path, FILE_CREATE_DIRECTORY);
$dir = drupal_realpath($path);
$files = file_scan_directory($dir, '/.*\\.(jpe?g|png|gif)/i', array(
'recurse' => FALSE,
));
foreach ($files as $file) {
$image = image_get_info($file->uri);
$file->filepath = $path . '/' . $file->filename;
$style_name = variable_get('user_badges_imagecache', '');
$variables = array(
'path' => $file->filepath,
);
if ($style_name) {
$theme = 'image_style';
$variables['style_name'] = $style_name;
}
else {
$theme = 'image';
$variables['width'] = $image['width'];
$variables['height'] = $image['height'];
}
$selects[$file->filepath] = (object) array(
'image' => theme($theme, $variables),
'file' => $file,
);
}
return $selects;
}