function _fupload_imagepreview_settings in Image FUpload 6
Same name and namespace in other branches
- 6.3 image_fupload.module \_fupload_imagepreview_settings()
- 6.2 image_fupload_image/image_fupload_image.admin.inc \_fupload_imagepreview_settings()
2 calls to _fupload_imagepreview_settings()
- image_fupload_image_admin in image_fupload_image/
image_fupload_image.admin.inc - image_fupload_image_admin_submit in image_fupload_image/
image_fupload_image.admin.inc
File
- image_fupload_image/
image_fupload_image.admin.inc, line 74
Code
function _fupload_imagepreview_settings($op, $node_type, $data_write = NULL) {
// switch to the right operation: what's up?
switch ($op) {
case 'list':
// generate a list of available presets for image_preview: image module or/and imagecache
$preview_presets_list = array();
// image module presets
if (module_exists('image') && $node_type == "image") {
$image_sizes = image_get_sizes();
foreach ($image_sizes as $key => $size) {
$preview_presets_list['image']['0_' . $key] = t('Image size') . ': ' . $size['label'];
}
}
// imagecache module presets
if (module_exists('imagecache')) {
$image_sizes = imagecache_presets();
foreach ($image_sizes as $key => $size) {
$preview_presets_list['imagecache']['1_' . $size['presetname']] = t('Image size') . ': ' . $size['presetname'];
}
}
//output list
return $preview_presets_list;
break;
case 'read':
// read actual setting for this node type
$image_node_types = variable_get('image_node_types', array());
switch ($node_type) {
case 'image':
// image node type
if (!empty($image_node_types['image']['image_selection'])) {
// image module preset
return '0_' . $image_node_types['image']['image_selection'];
}
elseif (!empty($image_node_types['image']['imagecache_preset'])) {
// imagecache module preset
return '1_' . $image_node_types['image']['imagecache_preset'];
}
else {
// no setting saved yet?
return '';
}
break;
default:
// node type with CCK ImageField
break;
}
break;
case 'write':
if (isset($data_write)) {
// is some data available?
// write input data to database
$image_node_types = variable_get('image_node_types', array());
switch ($node_type) {
case 'image':
// image node type
$image_node_types['image'] = array(
'title' => 'Image',
'fieldname' => 'images',
'image_selection' => $data_write['image_selection'],
'imagecache_preset' => $data_write['imagecache_preset'],
);
break;
default:
// node type with CCK ImageField
break;
}
// write data to database
variable_set('image_node_types', $image_node_types);
}
}
}