function _epsacrop_get_field_actions in EPSA Crop - Image Cropping 6
Same name and namespace in other branches
- 6.2 epsacrop.module \_epsacrop_get_field_actions()
Helper function for returning only imagecache preset actions with croping that was enabled for specific field.
Parameters
string $type_name: Content type machine name, e.g. 'page'.
string $field_name: CCK imagefield name, e.g. 'field_image'.
Return value
Structured array, e.g.: array( 0 => array( 'presetname' => 'presetname', 'width' => 400, 'height' => 300, ), 1 => ... )
2 calls to _epsacrop_get_field_actions()
- epsacrop_dialog in ./
epsacrop.module - Callback function for Dialog popup.
- theme_epsacrop_widget_item in ./
epsacrop.module - fonction theme qui ajouter le lien gérer le crop
File
- ./
epsacrop.module, line 613 - The main file of module
Code
function _epsacrop_get_field_actions($type_name, $field_name) {
$actions = _epsacrop_get_crop_actions();
$content_type = content_types($type_name);
$presets = $content_type['fields'][$field_name]['widget']['epsacrop_presets'];
if (!$presets['dont_show']) {
if (!empty($presets) && is_array($presets)) {
$presets = array_flip($presets);
foreach ($actions as $key => $action) {
if (!array_key_exists($action['presetname'], $presets)) {
unset($actions[$key]);
}
}
}
// Here we gonna strip the px after height and with
$_actions = array();
foreach ($actions as $key => $action) {
$_actions[$key] = array(
'presetname' => $action['presetname'],
'height' => (int) preg_replace('/[^0-9]+/', '', $action['height']),
'width' => (int) preg_replace('/[^0-9]+/', '', $action['width']),
);
}
}
return $_actions;
}