Issue #625958 followup by slashrsm, chx, andypost, yched: [Follow up] Support Uploading Multiple Files for HTML5 Browsers via #multiple attribute.
parent
a0c58c28a3
commit
2e63868616
|
@ -537,4 +537,3 @@ function field_update_8004() {
|
|||
* @} End of "addtogroup updates-7.x-to-8.x".
|
||||
* The next series of updates should start at 9000.
|
||||
*/
|
||||
|
||||
|
|
|
@ -259,32 +259,3 @@ function file_update_8001() {
|
|||
);
|
||||
db_change_field('file_usage', 'id', 'id', $spec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert image field's default image configuration to the new format.
|
||||
*/
|
||||
function file_update_8002() {
|
||||
if (module_exists('field_sql_storage')) {
|
||||
$fields = field_read_fields(array('type' => 'image'), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
|
||||
foreach ($fields as $field) {
|
||||
if (!empty($field['settings']['default_image'])) {
|
||||
$field['settings']['default_image'] = array($field['settings']['default_image']);
|
||||
}
|
||||
else {
|
||||
$field['settings']['default_image'] = array();
|
||||
}
|
||||
field_update_field($field);
|
||||
|
||||
$instances = field_read_instances(array('field_name' => $field['field_name']));
|
||||
foreach ($instances as $instance) {
|
||||
if (!empty($instance['settings']['default_image'])) {
|
||||
$instance['settings']['default_image'] = array($instance['settings']['default_image']);
|
||||
}
|
||||
else {
|
||||
$instance['settings']['default_image'] = array();
|
||||
}
|
||||
field_update_instance($instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1134,7 +1134,11 @@ function file_managed_file_submit($form, &$form_state) {
|
|||
$fids = array_diff($fids, $remove_fids);
|
||||
}
|
||||
else {
|
||||
// If we deal with single upload element remove the file and set
|
||||
// element's value to empty array (file could not be removed from
|
||||
// element if we don't do that).
|
||||
$remove_fids = $fids;
|
||||
$fids = array();
|
||||
}
|
||||
|
||||
foreach ($remove_fids as $fid) {
|
||||
|
|
|
@ -18,7 +18,7 @@ function image_field_info() {
|
|||
'description' => t('This field stores the ID of an image file as an integer value.'),
|
||||
'settings' => array(
|
||||
'uri_scheme' => file_default_scheme(),
|
||||
'default_image' => array(),
|
||||
'default_image' => 0,
|
||||
'column_groups' => array(
|
||||
'file' => array(
|
||||
'label' => t('File'),
|
||||
|
@ -44,7 +44,7 @@ function image_field_info() {
|
|||
'title_field_required' => 0,
|
||||
'max_resolution' => '',
|
||||
'min_resolution' => '',
|
||||
'default_image' => array(),
|
||||
'default_image' => 0,
|
||||
),
|
||||
'default_widget' => 'image_image',
|
||||
'default_formatter' => 'image',
|
||||
|
@ -79,7 +79,7 @@ function image_field_settings_form($field, $instance) {
|
|||
'#title' => t('Default image'),
|
||||
'#type' => 'managed_file',
|
||||
'#description' => t('If no image is uploaded, this image will be shown on display.'),
|
||||
'#default_value' => $field['settings']['default_image'],
|
||||
'#default_value' => empty($field['settings']['default_image']) ? array() : array($field['settings']['default_image']),
|
||||
'#upload_location' => $settings['uri_scheme'] . '://default_images/',
|
||||
);
|
||||
|
||||
|
@ -197,7 +197,7 @@ function image_field_instance_settings_form($field, $instance) {
|
|||
'#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'],
|
||||
'#default_value' => empty($settings['default_image']) ? array() : array($settings['default_image']),
|
||||
'#upload_location' => $field['settings']['uri_scheme'] . '://default_images/',
|
||||
);
|
||||
|
||||
|
@ -234,11 +234,11 @@ function image_field_prepare_view($entity_type, $entities, $field, $instances, $
|
|||
$fid = array();
|
||||
// Use the default for the instance if one is available.
|
||||
if (!empty($instances[$id]['settings']['default_image'])) {
|
||||
$fid = $instances[$id]['settings']['default_image'];
|
||||
$fid = array($instances[$id]['settings']['default_image']);
|
||||
}
|
||||
// Otherwise, use the default for the field.
|
||||
elseif (!empty($field['settings']['default_image'])) {
|
||||
$fid = $field['settings']['default_image'];
|
||||
$fid = array($field['settings']['default_image']);
|
||||
}
|
||||
|
||||
// Add the default image if one is found.
|
||||
|
|
|
@ -5,7 +5,10 @@
|
|||
* Exposes global functionality for creating image styles.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Language\Language;
|
||||
use Drupal\field\Plugin\Core\Entity\Field;
|
||||
use Drupal\field\Plugin\Core\Entity\FieldInstance;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
@ -369,7 +372,7 @@ function image_field_update_field($field, $prior_field, $has_data) {
|
|||
$fid_new = (isset($field['settings']['default_image']['fids']) ? $field['settings']['default_image']['fids'] : $field['settings']['default_image']);
|
||||
$fid_old = (isset($prior_field['settings']['default_image']['fids']) ? $prior_field['settings']['default_image']['fids'] : $prior_field['settings']['default_image']);
|
||||
|
||||
$file_new = $fid_new ? file_load($fid_new[0]) : FALSE;
|
||||
$file_new = $fid_new ? file_load($fid_new) : FALSE;
|
||||
|
||||
if ($fid_new != $fid_old) {
|
||||
|
||||
|
@ -1044,3 +1047,26 @@ function image_filter_keyword($value, $current_pixels, $new_pixels) {
|
|||
function _image_effect_definitions_sort($a, $b) {
|
||||
return strcasecmp($a['name'], $b['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_entity_presave().
|
||||
*
|
||||
* Transforms default image of image field from array into single value at save.
|
||||
*/
|
||||
function image_entity_presave(EntityInterface $entity, $type) {
|
||||
$field = FALSE;
|
||||
if ($entity instanceof FieldInstance) {
|
||||
$field = $entity->getField();
|
||||
}
|
||||
elseif ($entity instanceof Field) {
|
||||
$field = $entity;
|
||||
}
|
||||
if ($field && $field->type == 'image' && is_array($entity->settings['default_image'])) {
|
||||
if (!empty($entity->settings['default_image'][0])) {
|
||||
$entity->settings['default_image'] = $entity->settings['default_image'][0];
|
||||
}
|
||||
else {
|
||||
$entity->settings['default_image'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,10 +43,10 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
|
|||
// Create an image field and add an instance to the article content type.
|
||||
$field_name = strtolower($this->randomName());
|
||||
$field_settings = array(
|
||||
'default_image' => array($default_images['field']->fid),
|
||||
'default_image' => $default_images['field']->fid,
|
||||
);
|
||||
$instance_settings = array(
|
||||
'default_image' => array($default_images['instance']->fid),
|
||||
'default_image' => $default_images['instance']->fid,
|
||||
);
|
||||
$widget_settings = array(
|
||||
'preview_image_style' => 'medium',
|
||||
|
@ -63,7 +63,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
|
|||
'label' => $instance['label'],
|
||||
'required' => $instance['required'],
|
||||
'settings' => array(
|
||||
'default_image' => array($default_images['instance2']->fid),
|
||||
'default_image' => $default_images['instance2']->fid,
|
||||
),
|
||||
);
|
||||
field_create_instance($instance2);
|
||||
|
@ -179,7 +179,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
|
|||
);
|
||||
|
||||
// Upload a new default for the article's field instance.
|
||||
$instance['settings']['default_image'] = array($default_images['instance_new']->fid);
|
||||
$instance['settings']['default_image'] = $default_images['instance_new']->fid;
|
||||
field_update_instance($instance);
|
||||
|
||||
// Confirm the new field instance default is used on the article field
|
||||
|
@ -218,7 +218,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
|
|||
);
|
||||
|
||||
// Remove the instance default from articles.
|
||||
$instance['settings']['default_image'] = NULL;
|
||||
$instance['settings']['default_image'] = 0;
|
||||
field_update_instance($instance);
|
||||
|
||||
// Confirm the article field instance default has been removed.
|
||||
|
|
|
@ -232,7 +232,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
|
|||
// Clear field info cache so the new default image is detected.
|
||||
field_info_cache_clear();
|
||||
$field = field_info_field($field_name);
|
||||
$image = file_load($field['settings']['default_image'][0]);
|
||||
$image = file_load($field['settings']['default_image']);
|
||||
$this->assertTrue($image->status == FILE_STATUS_PERMANENT, 'The default image status is permanent.');
|
||||
$default_output = theme('image', array('uri' => $image->uri));
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
|
@ -274,7 +274,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
|
|||
field_info_cache_clear();
|
||||
|
||||
$private_field = field_info_field($private_field_name);
|
||||
$image = file_load($private_field['settings']['default_image'][0]);
|
||||
$image = file_load($private_field['settings']['default_image']);
|
||||
$this->assertEqual('private', file_uri_scheme($image->uri), 'Default image uses private:// scheme.');
|
||||
$this->assertTrue($image->status == FILE_STATUS_PERMANENT, 'The default image status is permanent.');
|
||||
// Create a new node with no image attached and ensure that default private
|
||||
|
|
|
@ -733,7 +733,7 @@ function user_update_8011() {
|
|||
'title_field' => 0,
|
||||
'max_resolution' => update_variable_get('user_picture_dimensions', '85x85'),
|
||||
'min_resolution' => '',
|
||||
'default_image' => !empty($default_image_fid) ? $default_image_fid : 0,
|
||||
'default_image' => !empty($default_image_fid) ? array($default_image_fid) : array(),
|
||||
),
|
||||
);
|
||||
_update_7000_field_create_instance($field, $instance);
|
||||
|
|
Loading…
Reference in New Issue