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.

CommentFileSizeAuthor
#3 3293185-3.patch1.4 KBdaniel korte
#2 3293185-2.patch1.43 KBdaniel korte

Comments

donquixote created an issue. See original summary.

daniel korte’s picture

Status: Active » Needs review
StatusFileSize
new1.43 KB
daniel korte’s picture

Version: 2.x-dev » 3.x-dev
StatusFileSize
new1.4 KB

Previous patch is for 2.x and this one is for 3.x

imyaro’s picture

Assigned: Unassigned » imyaro

  • Daniel Korte authored 6527909c on 8.x-1.x
    Issue #3293185 by Daniel Korte: Schema inconsistent: width/height empty...
imyaro’s picture

Status: Needs review » Fixed

Thanks for that patch, applied

  • Daniel Korte authored 6527909c on 3.x
    Issue #3293185 by Daniel Korte: Schema inconsistent: width/height empty...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.