function imageapi_optimize_info in Image Optimize (or ImageAPI Optimize) 7
Load all defined services and binaries info definitions.
4 calls to imageapi_optimize_info()
- imageapi_optimize_internal_binary_settings in services/
internal.inc - Form callback for Internal binary settings.
- imageapi_optimize_services_internal in services/
internal.inc - Internal ImageAPI Optimize service callback.
- image_imageapi_optimize_settings in ./
imageapi_optimize.module - Settings form callback for the image toolkit.
- _imageapi_optimize_optimize in ./
imageapi_optimize.module - Optimizes image with external commands.
File
- ./
imageapi_optimize.module, line 256 - Image optimize functionalities.
Code
function imageapi_optimize_info($reset = FALSE) {
$cache = cache_get('imageapi_optimize:info');
if (!$cache || $reset) {
$info = module_invoke_all('imageapi_optimize_info');
drupal_alter('imageapi_optimize_info', $info);
// Process and validate all defined info.
foreach ($info as $type => &$types) {
foreach ($types as $name => &$data) {
// Set defaults.
$data += array(
'callbacks' => array(),
'weight' => 0,
);
$data['callbacks'] += array(
'process' => 'imageapi_optimize_' . $type . '_' . $name,
);
// Add form callback if undefined yet available.
if (!isset($data['callbacks']['form'])) {
$function = 'imageapi_optimize_' . $type . '_' . $name . '_form';
if (function_exists($function)) {
$data['callbacks']['form'] = $function;
}
}
// Set user defined binaries weight if available.
if ('binaries' == $type) {
$settings = variable_get('imageapi_optimize_' . $name, array());
$data['weight'] = isset($settings['weight']) ? $settings['weight'] : $data['weight'];
if (empty($data['settings'])) {
$data['settings'] = array();
}
}
// Validate info.
$error = '';
if (!isset($data['title'])) {
$error .= t('Title not set.') . '<br />';
}
foreach ($data['callbacks'] as $callback) {
if (!function_exists($callback)) {
$error .= t('Function !callback does not exist.', array(
'!callback' => $callback,
)) . '<br />';
}
}
if (isset($data['file']) && !file_exists($data['file'])) {
$error .= t('File @file does not exist.', array(
'@file' => $data['file'],
)) . '<br />';
}
if (!empty($error)) {
unset($info[$type][$name]);
watchdog('imageapi_optimize', $error);
}
}
// Sort by weight.
uasort($info[$type], 'drupal_sort_weight');
}
// Cache the info to reduce future load times.
cache_set('imageapi_optimize:info', $info);
return $info;
}
return $cache->data;
}