Schema inconsistent: width/height empty string vs null vs integer

Created on 28 June 2022, over 2 years ago
Updated 28 October 2023, about 1 year ago

When saving a view mode through the UI, if width/height settings for a formatter are left empty, the width/height are saved as null.
But when just running the image_post_update_image_loading_attribute() core update hook, they are saved as empty string.

This is due to this:

  /**
   * {@inheritdoc}
   */
  public static function defaultSettings() {
    return [
        'svg_attributes' => ['width' => '', 'height' => ''], 'svg_render_as_image' => TRUE,
      ] + parent::defaultSettings();
  }

Replace with null and it will behave more consistently I think.

  /**
   * {@inheritdoc}
   */
  public static function defaultSettings() {
    return [
        'svg_attributes' => ['width' => null, 'height' => null], 'svg_render_as_image' => TRUE,
      ] + parent::defaultSettings();
  }

We should also set 'nullable: true' in the schema for these fields.

πŸ“Œ Task
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany donquixote

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024