diff -u b/core/modules/image/image.field.inc b/core/modules/image/image.field.inc --- b/core/modules/image/image.field.inc +++ b/core/modules/image/image.field.inc @@ -363,26 +363,23 @@ ); } - // The following code dealing with limit validation errors is the logic that - // avoids triggering error messages on elements that are accompanying the - // field element. These are alt and title elements. The idea is to dynamically - // build the definition of which fields should not be validated. + // Verify if alt and title elements are present & then dynamically build the + // definition of which fields should not be validated. if ($settings['alt_field_required'] || $settings['title_field_required']) { // Set helper container for collecting limit_validation_errors definitions. if (!isset($form_state['_limit_validation_errors'])) { $form_state['_limit_validation_errors'] = array(); } - // In case the triggering element is not set - form is being rendered - or in - // case the rendering element is "Upload" - user uploaded new file - build - // the limit validation error array. + // Build the limit validation error array if the triggering element is not + // set or for rendering the Upload element for a new file. if (!isset($form_state['triggering_element']) || $form_state['triggering_element']['#value'] == t('Upload')) { - // For files that have just been uploaded validate only the fid. + // For files that have just been uploaded validate only the file ID. if (empty($element['#file']) || empty($element['#file']->status)) { $form_state['_limit_validation_errors'][$element['#delta']] = array($instance['field_name'], $element['#language'], $element['#delta'], 'fid'); - // Here we need to set the alt and title values from POST as the limit - // validation logic will remove them from form_state. + // Set alt and title values from POST as the limit validation logic will + // remove them from the form_state. if ($element['#alt_field'] && isset($_POST[$instance['field_name']][$element['#language']][$element['#delta']]['alt'])) { $item['alt'] = $_POST[$instance['field_name']][$element['#language']][$element['#delta']]['alt']; } @@ -390,14 +387,13 @@ $item['title'] = $_POST[$instance['field_name']][$element['#language']][$element['#delta']]['title']; } } - // Previously uploaded files - validate whole field. + // Validate the whole field for previously uploaded files. else { $form_state['_limit_validation_errors'][$element['#delta']] = array($instance['field_name'], $element['#language'], $element['#delta']); } } - // Set the built limit validation error definition array for upload as well as - // for the remove button. + // Limit validation errors for the upload and remove buttons. $element['upload_button']['#limit_validation_errors'] = $form_state['_limit_validation_errors']; $element['remove_button']['#limit_validation_errors'] = $form_state['_limit_validation_errors']; }