From 14f76e50b311d596b97008f376b6fcb7ebaf9303 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Tue, 16 Jan 2018 14:01:42 +0100 Subject: [PATCH] Add missing alt attribute to image (and gallery) blocks when alt return an empty value (#4363) --- .../api/raw-handling/test/integration/google-docs-out.html | 2 +- .../raw-handling/test/integration/ms-word-online-out.html | 2 +- blocks/api/raw-handling/test/integration/ms-word-out.html | 2 +- blocks/library/gallery/index.js | 1 + blocks/library/image/index.js | 1 + blocks/test/fixtures/core__image.html | 2 +- blocks/test/fixtures/core__image.json | 5 +++-- blocks/test/fixtures/core__image.parsed.json | 2 +- blocks/test/fixtures/core__image.serialized.html | 2 +- blocks/test/fixtures/core__image__center-caption.html | 2 +- blocks/test/fixtures/core__image__center-caption.json | 5 +++-- blocks/test/fixtures/core__image__center-caption.parsed.json | 2 +- .../fixtures/core__image__center-caption.serialized.html | 2 +- 13 files changed, 17 insertions(+), 13 deletions(-) diff --git a/blocks/api/raw-handling/test/integration/google-docs-out.html b/blocks/api/raw-handling/test/integration/google-docs-out.html index 8cb94dc1bbcb8..d8242c4779198 100644 --- a/blocks/api/raw-handling/test/integration/google-docs-out.html +++ b/blocks/api/raw-handling/test/integration/google-docs-out.html @@ -60,6 +60,6 @@

This is a heading

-
+
diff --git a/blocks/api/raw-handling/test/integration/ms-word-online-out.html b/blocks/api/raw-handling/test/integration/ms-word-online-out.html index 997359fa84037..d7d6370dfc3ba 100644 --- a/blocks/api/raw-handling/test/integration/ms-word-online-out.html +++ b/blocks/api/raw-handling/test/integration/ms-word-online-out.html @@ -50,5 +50,5 @@ -
+
diff --git a/blocks/api/raw-handling/test/integration/ms-word-out.html b/blocks/api/raw-handling/test/integration/ms-word-out.html index 3f4687910c6ce..b5d2e6ba1ca54 100644 --- a/blocks/api/raw-handling/test/integration/ms-word-out.html +++ b/blocks/api/raw-handling/test/integration/ms-word-out.html @@ -85,5 +85,5 @@

This is a heading level 2

-
+
diff --git a/blocks/library/gallery/index.js b/blocks/library/gallery/index.js index 2fc8fbdf6344c..5d20879114423 100644 --- a/blocks/library/gallery/index.js +++ b/blocks/library/gallery/index.js @@ -42,6 +42,7 @@ registerBlockType( 'core/gallery', { alt: { source: 'attribute', attribute: 'alt', + default: '', }, id: { source: 'attribute', diff --git a/blocks/library/image/index.js b/blocks/library/image/index.js index 3a49ee6e8a416..dbabc408dcd31 100644 --- a/blocks/library/image/index.js +++ b/blocks/library/image/index.js @@ -35,6 +35,7 @@ registerBlockType( 'core/image', { source: 'attribute', selector: 'img', attribute: 'alt', + default: '', }, caption: { type: 'array', diff --git a/blocks/test/fixtures/core__image.html b/blocks/test/fixtures/core__image.html index 2a414855b0344..eda663561a38b 100644 --- a/blocks/test/fixtures/core__image.html +++ b/blocks/test/fixtures/core__image.html @@ -1,3 +1,3 @@ -
+
diff --git a/blocks/test/fixtures/core__image.json b/blocks/test/fixtures/core__image.json index 89bdd5ba93cbc..0aaa9b4804a96 100644 --- a/blocks/test/fixtures/core__image.json +++ b/blocks/test/fixtures/core__image.json @@ -5,8 +5,9 @@ "isValid": true, "attributes": { "url": "https://cldup.com/uuUqE_dXzy.jpg", - "caption": [] + "caption": [], + "alt": "" }, - "originalContent": "
" + "originalContent": "
\"\"
" } ] diff --git a/blocks/test/fixtures/core__image.parsed.json b/blocks/test/fixtures/core__image.parsed.json index 4e50ecd68576d..eba958b3ec9a3 100644 --- a/blocks/test/fixtures/core__image.parsed.json +++ b/blocks/test/fixtures/core__image.parsed.json @@ -3,7 +3,7 @@ "blockName": "core/image", "attrs": null, "innerBlocks": [], - "innerHTML": "\n
\n" + "innerHTML": "\n
\"\"
\n" }, { "attrs": {}, diff --git a/blocks/test/fixtures/core__image.serialized.html b/blocks/test/fixtures/core__image.serialized.html index fb41212fe367e..bbe320d2bc140 100644 --- a/blocks/test/fixtures/core__image.serialized.html +++ b/blocks/test/fixtures/core__image.serialized.html @@ -1,3 +1,3 @@ -
+
diff --git a/blocks/test/fixtures/core__image__center-caption.html b/blocks/test/fixtures/core__image__center-caption.html index 1973035e7c6e6..4fbce9c6fafd7 100644 --- a/blocks/test/fixtures/core__image__center-caption.html +++ b/blocks/test/fixtures/core__image__center-caption.html @@ -1,3 +1,3 @@ -
Give it a try. Press the "really wide" button on the image toolbar.
+
Give it a try. Press the "really wide" button on the image toolbar.
diff --git a/blocks/test/fixtures/core__image__center-caption.json b/blocks/test/fixtures/core__image__center-caption.json index c5465d7896235..dfd4d57389ac5 100644 --- a/blocks/test/fixtures/core__image__center-caption.json +++ b/blocks/test/fixtures/core__image__center-caption.json @@ -8,8 +8,9 @@ "caption": [ "Give it a try. Press the \"really wide\" button on the image toolbar." ], - "align": "center" + "align": "center", + "alt": "" }, - "originalContent": "
Give it a try. Press the "really wide" button on the image toolbar.
" + "originalContent": "
\"\"
Give it a try. Press the "really wide" button on the image toolbar.
" } ] diff --git a/blocks/test/fixtures/core__image__center-caption.parsed.json b/blocks/test/fixtures/core__image__center-caption.parsed.json index b32c1f8fd1a0f..abd5611da1948 100644 --- a/blocks/test/fixtures/core__image__center-caption.parsed.json +++ b/blocks/test/fixtures/core__image__center-caption.parsed.json @@ -5,7 +5,7 @@ "align": "center" }, "innerBlocks": [], - "innerHTML": "\n
Give it a try. Press the "really wide" button on the image toolbar.
\n" + "innerHTML": "\n
\"\"
Give it a try. Press the "really wide" button on the image toolbar.
\n" }, { "attrs": {}, diff --git a/blocks/test/fixtures/core__image__center-caption.serialized.html b/blocks/test/fixtures/core__image__center-caption.serialized.html index 3dffbf76bc841..7b7acfcd4d09d 100644 --- a/blocks/test/fixtures/core__image__center-caption.serialized.html +++ b/blocks/test/fixtures/core__image__center-caption.serialized.html @@ -1,5 +1,5 @@ -
+
Give it a try. Press the "really wide" button on the image toolbar.