function image_ncck_widget_settings in Embedded Media Field 5
File
- contrib/
image_ncck/ image_ncck.module, line 141
Code
function image_ncck_widget_settings($op, $widget) {
switch ($op) {
case 'form':
$form = (array) module_invoke('emfield', 'emfield_widget_settings', 'form', $widget, 'image_ncck');
if ($widget['type'] == 'image_ncck_textfields') {
$link_options = array(
IMAGE_NCCK_LINK_NONE => t('No link'),
IMAGE_NCCK_LINK_CONTENT => t('Link to content'),
IMAGE_NCCK_LINK_PROVIDER => t('Link to provider'),
);
$width = IMAGE_NCCK_DEFAULT_FULL_WIDTH;
$height = IMAGE_NCCK_DEFAULT_FULL_HEIGHT;
$form['full'] = array(
'#type' => 'fieldset',
'#title' => t('Full size display settings'),
'#description' => t('These settings control how this image is displayed in its full size, which defaults to @widthx@height. Note that if one of the dimensions is 0, then the image will be resized to be no larger than the other dimension.', array(
'@width' => $width,
'@height' => $height,
)),
'#collapsible' => true,
'#collapsed' => false,
);
$form['full']['full_width'] = array(
'#type' => 'textfield',
'#title' => t('Full size display width'),
'#default_value' => $widget['full_width'] === '' ? $width : $widget['full_width'],
'#required' => true,
'#description' => t('The width of the image. It defaults to @width. Set it to 0 if you want to leave the image at its original aspect ratio.', array(
'@width' => $width,
)),
);
$form['full']['full_height'] = array(
'#type' => 'textfield',
'#title' => t('Full size display height'),
'#default_value' => $widget['full_height'] === '' ? $height : $widget['full_height'],
'#required' => true,
'#description' => t('The height of the image. It defaults to @height. Set it to 0 if you want to leave the image at its original aspect ratio.', array(
'@height' => $height,
)),
);
$form['full']['full_link'] = array(
'#type' => 'select',
'#title' => t('Full size link'),
'#description' => t('Where the image will link when displayed in its full size. \'Content\' links to the content page, \'provider\' links to the provider\'s image page, and \'none\' displays the image with no link.'),
'#options' => $link_options,
'#default_value' => $widget['full_link'] === '' ? IMAGE_NCCK_DEFAULT_FULL_LINK : $widget['full_link'],
);
$width = IMAGE_NCCK_DEFAULT_PREVIEW_WIDTH;
$height = IMAGE_NCCK_DEFAULT_PREVIEW_HEIGHT;
$form['preview'] = array(
'#type' => 'fieldset',
'#title' => t('Image Preview Settings'),
'#description' => t('These settings control how this image is displayed in its preview size, which defaults to @widthx@height. Note that if one of the dimensions is 0, then the image will be resized to be no larger than the other dimension.', array(
'@width' => $width,
'@height' => $height,
)),
'#collapsible' => true,
'#collapsed' => false,
);
$form['preview']['preview_width'] = array(
'#type' => 'textfield',
'#title' => t('Image preview width'),
'#default_value' => $widget['preview_width'] === '' ? $width : $widget['preview_width'],
'#required' => true,
'#description' => t('The width of the image preview. It defaults to @width. Set it to 0 if you want to leave the image at its original aspect ratio.', array(
'@width' => $width,
)),
);
$form['preview']['preview_height'] = array(
'#type' => 'textfield',
'#title' => t('Image preview height'),
'#default_value' => $widget['preview_height'] === '' ? $height : $widget['preview_height'],
'#required' => true,
'#description' => t('The height of the image preview. It defaults to @height. Set it to 0 if you want to leave the image at its original aspect ratio.', array(
'@height' => $height,
)),
);
$form['preview']['preview_link'] = array(
'#type' => 'select',
'#title' => t('Preview size link'),
'#description' => t('Where the image will link when displayed in its preview size. \'Content\' links to the content page, \'provider\' links to the provider\'s image page, and \'none\' displays the image with no link.'),
'#options' => $link_options,
'#default_value' => $widget['preview_link'] === '' ? IMAGE_NCCK_DEFAULT_PREVIEW_LINK : $widget['preview_link'],
);
$width = IMAGE_NCCK_DEFAULT_THUMBNAIL_WIDTH;
$height = IMAGE_NCCK_DEFAULT_THUMBNAIL_HEIGHT;
$form['tn'] = array(
'#type' => 'fieldset',
'#title' => t('Thumbnail'),
'#description' => t('When displayed as a thumbnail, these settings control the image returned. The default size for thumbnails is @widthx@height. Note that if one of the dimensions is 0, then the image will be resized to be no larger than the other dimension.', array(
'@width' => $width,
'@height' => $height,
)),
'#collapsible' => true,
'#collapsed' => false,
);
$form['tn']['thumbnail_width'] = array(
'#type' => 'textfield',
'#title' => t('Image thumbnail width'),
'#default_value' => $widget['thumbnail_width'] === '' ? $width : $widget['thumbnail_width'],
'#required' => true,
'#description' => t('The width of the image thumbnail. It defaults to @width. Set it to 0 if you want to leave the image at its original aspect ratio.', array(
'@width' => $width,
)),
);
$form['tn']['thumbnail_height'] = array(
'#type' => 'textfield',
'#title' => t('Image thumbnail height'),
'#default_value' => $widget['thumbnail_height'] === '' ? $height : $widget['thumbnail_height'],
'#required' => true,
'#description' => t('The height of the image thumbnail. It defaults to @height. Set it to 0 if you want to leave the image at its original aspect ratio.', array(
'@height' => $height,
)),
);
$form['tn']['thumbnail_link'] = array(
'#type' => 'select',
'#title' => t('Image thumbnail link'),
'#description' => t('Where the image will link when displayed as a thumbnail. \'Content\' links to the content page, \'provider\' links to the provider\'s image page, and \'none\' displays the image with no link.'),
'#options' => $link_options,
'#default_value' => $widget['thumbnail_link'] === '' ? IMAGE_NCCK_DEFAULT_THUMBNAIL_LINK : $widget['thumbnail_link'],
);
}
return $form;
case 'validate':
if ($widget['type'] == 'image_ncck_textfields') {
if (!is_numeric($widget['full_width']) || intval($widget['full_width']) != $widget['full_width'] || $widget['full_width'] < 0) {
form_set_error('full_width', t('"Full size width" must be an integer.'));
}
if (!is_numeric($widget['full_height']) || intval($widget['full_height']) != $widget['full_height'] || $widget['full_height'] < 0) {
form_set_error('full_height', t('"Full size height" must be an integer.'));
}
if (!is_numeric($widget['preview_width']) || intval($widget['preview_width']) != $widget['preview_width'] || $widget['preview_width'] < 0) {
form_set_error('preview_width', t('"Preview width" must be an integer.'));
}
if (!is_numeric($widget['preview_height']) || intval($widget['preview_height']) != $widget['preview_height'] || $widget['preview_height'] < 0) {
form_set_error('preview_height', t('"Preview height" must be an integer.'));
}
if (!is_numeric($widget['thumbnail_width']) || intval($widget['thumbnail_width']) != $widget['thumbnail_width'] || $widget['thumbnail_width'] < 0) {
form_set_error('thumbnail_width', t('"Thumbnail width" must be an integer.'));
}
if (!is_numeric($widget['thumbnail_height']) || intval($widget['thumbnail_height']) != $widget['thumbnail_height'] || $widget['thumbnail_height'] < 0) {
form_set_error('thumbnail_height', t('"Thumbnail height" must be an integer.'));
}
}
break;
case 'save':
if ($widget['widget']['type'] == 'image_ncck_textfields') {
$columns = array(
'full_width',
'full_height',
'full_link',
'preview_width',
'preview_height',
'preview_link',
'thumbnail_width',
'thumbnail_height',
'thumbnail_link',
);
$columns = array_merge($columns, module_invoke('emfield', 'emfield_widget_settings', 'save', $widget, 'image_ncck'));
return $columns;
}
break;
}
}