Closed (fixed)
Project:
EPSA Crop - Image Cropping
Version:
6.x-1.3
Component:
User interface
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
5 Mar 2012 at 18:20 UTC
Updated:
13 Mar 2014 at 15:09 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
gerson.analista commentedI agree with naeluh this is a very important option.
Comment #2
gerson.analista commentedI did a change to implement this functionality in this module.
On file epsacrop.module
On the functiom on line 605.
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 (!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;
}
I change for:
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;
}
And on the functiom on line 635.
function epsacrop_widget_settings_alter(&$settings, $op, $widget) {
$widget_type = isset($widget['widget_type']) ? $widget['widget_type'] : $widget['type'];
// Alter only imagefied_widget
if (!stristr($widget_type, 'imagefield_widget')) {
return;
}
// Add our new options to the list of settings to be saved.
if ($op == 'save') {
$settings = array_merge($settings, array('epsacrop_presets'));
}
// Add the additional settings to the form.
$presets['dont_show']=t("Don't show.");
$presets += _epsacrop_get_crop_presets();
if ($op == 'form') {
$settings['epsacrop'] = array(
'#type' => 'fieldset',
'#title' => t('EPSA Crop'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('These options allow the user to pick imagecache presets that would be available to crop.'),
'#weight' => 15,
);
$settings['epsacrop']['epsacrop_presets'] = array(
'#title' => t('Imagecache presets'),
'#type' => 'checkboxes',
'#default_value' => (($widget['epsacrop_presets'] != NULL) ? $widget['epsacrop_presets'] : array()),
'#options' => $presets,
'#description' => t('Only presets utilising crop filter are available'),
);
}
}
I change for:
function epsacrop_widget_settings_alter(&$settings, $op, $widget) {
$widget_type = isset($widget['widget_type']) ? $widget['widget_type'] : $widget['type'];
// Alter only imagefied_widget
if (!stristr($widget_type, 'imagefield_widget')) {
return;
}
// Add our new options to the list of settings to be saved.
if ($op == 'save') {
$settings = array_merge($settings, array('epsacrop_presets'));
}
// Add the additional settings to the form.
$presets['dont_show']=t("Don't show.");
$presets += _epsacrop_get_crop_presets();
if ($op == 'form') {
$settings['epsacrop'] = array(
'#type' => 'fieldset',
'#title' => t('EPSA Crop'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('These options allow the user to pick imagecache presets that would be available to crop.'),
'#weight' => 15,
);
$settings['epsacrop']['epsacrop_presets'] = array(
'#title' => t('Imagecache presets'),
'#type' => 'checkboxes',
'#default_value' => (($widget['epsacrop_presets'] != NULL) ? $widget['epsacrop_presets'] : array()),
'#options' => $presets,
'#description' => t('Only presets utilising crop filter are available'),
);
}
}
basically I added 3 lines in code.
Comment #3
yvmarques commented