Skip to content

Commit

Permalink
Add missing alt attribute to image (and gallery) blocks when alt retu…
Browse files Browse the repository at this point in the history
…rn an empty value (#4363)
  • Loading branch information
audrasjb authored and youknowriad committed Jan 16, 2018
1 parent 6c65025 commit 14f76e5
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ <h2>This is a <em>heading</em></h2>
<!-- /wp:paragraph -->

<!-- wp:image -->
<figure class="wp-block-image"><img src="https://lh4.googleusercontent.com/ID" /></figure>
<figure class="wp-block-image"><img src="https://lh4.googleusercontent.com/ID" alt="" /></figure>
<!-- /wp:image -->

Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@
<!-- /wp:paragraph -->

<!-- wp:image -->
<figure class="wp-block-image"><img src="" /></figure>
<figure class="wp-block-image"><img src="" alt="" /></figure>
<!-- /wp:image -->
2 changes: 1 addition & 1 deletion blocks/api/raw-handling/test/integration/ms-word-out.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ <h2>This is a heading level 2</h2>
<!-- /wp:paragraph -->

<!-- wp:image -->
<figure class="wp-block-image"><img src="" /></figure>
<figure class="wp-block-image"><img src="" alt="" /></figure>
<!-- /wp:image -->
1 change: 1 addition & 0 deletions blocks/library/gallery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ registerBlockType( 'core/gallery', {
alt: {
source: 'attribute',
attribute: 'alt',
default: '',
},
id: {
source: 'attribute',
Expand Down
1 change: 1 addition & 0 deletions blocks/library/image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ registerBlockType( 'core/image', {
source: 'attribute',
selector: 'img',
attribute: 'alt',
default: '',
},
caption: {
type: 'array',
Expand Down
2 changes: 1 addition & 1 deletion blocks/test/fixtures/core__image.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:core/image -->
<figure class="wp-block-image"><img src="https://cldup.com/uuUqE_dXzy.jpg" /></figure>
<figure class="wp-block-image"><img src="https://cldup.com/uuUqE_dXzy.jpg" alt="" /></figure>
<!-- /wp:core/image -->
5 changes: 3 additions & 2 deletions blocks/test/fixtures/core__image.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"isValid": true,
"attributes": {
"url": "https://cldup.com/uuUqE_dXzy.jpg",
"caption": []
"caption": [],
"alt": ""
},
"originalContent": "<figure class=\"wp-block-image\"><img src=\"https://cldup.com/uuUqE_dXzy.jpg\" /></figure>"
"originalContent": "<figure class=\"wp-block-image\"><img src=\"https://cldup.com/uuUqE_dXzy.jpg\" alt=\"\" /></figure>"
}
]
2 changes: 1 addition & 1 deletion blocks/test/fixtures/core__image.parsed.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"blockName": "core/image",
"attrs": null,
"innerBlocks": [],
"innerHTML": "\n<figure class=\"wp-block-image\"><img src=\"https://cldup.com/uuUqE_dXzy.jpg\" /></figure>\n"
"innerHTML": "\n<figure class=\"wp-block-image\"><img src=\"https://cldup.com/uuUqE_dXzy.jpg\" alt=\"\" /></figure>\n"
},
{
"attrs": {},
Expand Down
2 changes: 1 addition & 1 deletion blocks/test/fixtures/core__image.serialized.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:image -->
<figure class="wp-block-image"><img src="https://cldup.com/uuUqE_dXzy.jpg" /></figure>
<figure class="wp-block-image"><img src="https://cldup.com/uuUqE_dXzy.jpg" alt="" /></figure>
<!-- /wp:image -->
2 changes: 1 addition & 1 deletion blocks/test/fixtures/core__image__center-caption.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:core/image {"align":"center"} -->
<figure class="wp-block-image aligncenter"><img src="https://cldup.com/YLYhpou2oq.jpg"/><figcaption>Give it a try. Press the &quot;really wide&quot; button on the image toolbar.</figcaption></figure>
<figure class="wp-block-image aligncenter"><img src="https://cldup.com/YLYhpou2oq.jpg" alt="" /><figcaption>Give it a try. Press the &quot;really wide&quot; button on the image toolbar.</figcaption></figure>
<!-- /wp:core/image -->
5 changes: 3 additions & 2 deletions blocks/test/fixtures/core__image__center-caption.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
"caption": [
"Give it a try. Press the \"really wide\" button on the image toolbar."
],
"align": "center"
"align": "center",
"alt": ""
},
"originalContent": "<figure class=\"wp-block-image aligncenter\"><img src=\"https://cldup.com/YLYhpou2oq.jpg\"/><figcaption>Give it a try. Press the &quot;really wide&quot; button on the image toolbar.</figcaption></figure>"
"originalContent": "<figure class=\"wp-block-image aligncenter\"><img src=\"https://cldup.com/YLYhpou2oq.jpg\" alt=\"\" /><figcaption>Give it a try. Press the &quot;really wide&quot; button on the image toolbar.</figcaption></figure>"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"align": "center"
},
"innerBlocks": [],
"innerHTML": "\n<figure class=\"wp-block-image aligncenter\"><img src=\"https://cldup.com/YLYhpou2oq.jpg\"/><figcaption>Give it a try. Press the &quot;really wide&quot; button on the image toolbar.</figcaption></figure>\n"
"innerHTML": "\n<figure class=\"wp-block-image aligncenter\"><img src=\"https://cldup.com/YLYhpou2oq.jpg\" alt=\"\" /><figcaption>Give it a try. Press the &quot;really wide&quot; button on the image toolbar.</figcaption></figure>\n"
},
{
"attrs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- wp:image {"align":"center"} -->
<figure class="wp-block-image aligncenter"><img src="https://cldup.com/YLYhpou2oq.jpg" />
<figure class="wp-block-image aligncenter"><img src="https://cldup.com/YLYhpou2oq.jpg" alt="" />
<figcaption>Give it a try. Press the &quot;really wide&quot; button on the image toolbar.</figcaption>
</figure>
<!-- /wp:image -->

0 comments on commit 14f76e5

Please sign in to comment.