diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2012-04-30 21:25:39 -0700 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2012-04-30 21:25:39 -0700 |
commit | d0b5d31cbca7b5ce521ee180b6ca31e301b63b4e (patch) | |
tree | b28610c70815d08a95e38a5534a858457ed69117 /modules/image/image.field.inc | |
parent | 84c4f7622e8cd2c90374e3907069aa256114558f (diff) | |
download | brdo-d0b5d31cbca7b5ce521ee180b6ca31e301b63b4e.tar.gz brdo-d0b5d31cbca7b5ce521ee180b6ca31e301b63b4e.tar.bz2 |
Issue #751168 by elliotttf, caktux, andyceo, setvik, xjm, sun, tim.plunkett: Fixed Regression: Missing 'Default image' per field instance.
Diffstat (limited to 'modules/image/image.field.inc')
-rw-r--r-- | modules/image/image.field.inc | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/modules/image/image.field.inc b/modules/image/image.field.inc index e56e0cf49..854e6303d 100644 --- a/modules/image/image.field.inc +++ b/modules/image/image.field.inc @@ -25,6 +25,7 @@ function image_field_info() { 'title_field' => 0, 'max_resolution' => '', 'min_resolution' => '', + 'default_image' => 0, ), 'default_widget' => 'image_image', 'default_formatter' => 'image', @@ -152,6 +153,15 @@ function image_field_instance_settings_form($field, $instance) { '#weight' => 11, ); + // Add the default image to the instance. + $form['default_image'] = array( + '#title' => t('Default image'), + '#type' => 'managed_file', + '#description' => t("If no image is uploaded, this image will be shown on display and will override the field's default image."), + '#default_value' => $settings['default_image'], + '#upload_location' => $field['settings']['uri_scheme'] . '://default_images/', + ); + return $form; } @@ -191,8 +201,19 @@ function image_field_load($entity_type, $entities, $field, $instances, $langcode function image_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) { // If there are no files specified at all, use the default. foreach ($entities as $id => $entity) { - if (empty($items[$id]) && $field['settings']['default_image']) { - if ($file = file_load($field['settings']['default_image'])) { + if (empty($items[$id])) { + $fid = 0; + // Use the default for the instance if one is available. + if ($instances[$id]['settings']['default_image']) { + $fid = $instances[$id]['settings']['default_image']; + } + // Otherwise, use the default for the field. + elseif ($field['settings']['default_image']) { + $fid = $field['settings']['default_image']; + } + + // Add the default image if one is found. + if ($fid && ($file = file_load($fid))) { $items[$id][0] = (array) $file + array( 'is_default' => TRUE, 'alt' => '', |