Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing alt attribute to image (and gallery) blocks when alt return an empty value #4363

Merged
merged 7 commits into from
Jan 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 -->