Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By lukasss on
I need to add additional settings for the image in image field.
I created a checkbox and table in the database to store state:
function l_watermark_field_widget_image_image_form_alter(&$element, &$form_state, $context) {
if ($element['#field_name']=='field_img') {
foreach (element_children($element) as $key => $child) {
// Add the new process function to the element
if ($element[$key]['#type']=='managed_file' && $element[$key]['#field_name']=='field_img') {
$element[$key]['#process'][] = 'l_watermark_image_field_widget_process';
}
}
}
}
function l_watermark_image_field_widget_process($element, &$form_state, $form) {
$attributes = array(
'data' => $element['#file']->fid,
'class' => array('l_watermark'),
);
if (l_watermark_fid_yes($element['#file']->fid)) {
$attributes['checked'] = 'checked';
}
$element['l_watermark'] = array(
'#type' => 'checkbox',
'#title' => t('Watermark'),
'#default_value' => false,
'#description' => t('Photo will be put on Watermark'),
'#attributes' => $attributes,
);
return $element;
}
function l_watermark_fid_yes($fid) {
$count = db_select('l_watermark', 'lw')
->condition('lw.fid', $fid)
->countQuery()
->execute()
->fetchField();
return $count;
}
in install file:
function l_watermark_schema() {
$schema['l_watermark'] = array(
'description' => 'The base table for l_watermark.',
'fields' => array(
'id' => array(
'description' => 'The primary identifier for a l_watermark.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'fid' => array(
'description' => 'The file fid that owns this l_watermark.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'primary key' => array('id'),
'indexes' => array(
'fid' => array('fid'),
),
);
return $schema;
}
How can I get the value for each image, example in submite node form?
Thanks for any ideas!
Comments
Any ideas, Please!!!
Any ideas, Please!!!
For world peace!
Any ideas, Please!!!
Any ideas, Please!!!
For world peace!
Use hook_node_insert() [and
Use hook_node_insert() [and hook_node_update()], and dump $node. You should see your values in there.
Thank you very much. You
Thank you very much. You moved me off the ground!
This is was so easy!
For world peace!