Skip to content

Commit

Permalink
Switch attributes to use img attributes and not add data attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
mkaz committed Jun 1, 2017
1 parent 70550fc commit 30e366b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion blocks/library/gallery/gallery-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export default class GalleryImage extends wp.element.Component {
render() {
return (
<div key={ this.props.i } className="blocks-gallery-image" data-url={ this.props.img.url } data-alt={ this.props.img.alt }>
<div key={ this.props.i } className="blocks-gallery-image">
<img src={ this.props.img.url } alt={ this.props.img.alt } />
</div>
);
Expand Down
6 changes: 3 additions & 3 deletions blocks/library/gallery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ registerBlock( 'core/gallery', {

attributes: {
images:
query( 'div.blocks-gallery div.blocks-gallery-image', {
url: attr( 'data-url' ),
alt: attr( 'data-alt' ),
query( 'div.blocks-gallery div.blocks-gallery-image img', {
url: attr( 'src' ),
alt: attr( 'alt' ),
} ),
},

Expand Down
4 changes: 2 additions & 2 deletions blocks/test/fixtures/core-gallery.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!-- wp:core/gallery -->
<div class="blocks-gallery">
<div class="blocks-gallery-image">
<img src="https://cldup.com/uuUqE_dXzy.jpg" alt="title"/>
<img src="https://cldup.com/uuUqE_dXzy.jpg" alt="title" />
</div>
<div class="blocks-gallery-image">
<img src="https://cldup.com/uuUqE_dXzy.jpg" alt="title"/>
<img src="https://cldup.com/uuUqE_dXzy.jpg" alt="title" />
</div>
</div>
<!-- /wp:core/gallery -->
4 changes: 2 additions & 2 deletions blocks/test/fixtures/core-gallery.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"blockType": "core/gallery",
"attributes": {
"images": [
{},
{}
{ "url": "https://cldup.com/uuUqE_dXzy.jpg", "alt": "title" },
{ "url": "https://cldup.com/uuUqE_dXzy.jpg", "alt": "title" }
]
}
}
Expand Down
4 changes: 2 additions & 2 deletions blocks/test/fixtures/core-gallery.serialized.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- wp:core/gallery -->
<div class="blocks-gallery alignnone">
<div class="blocks-gallery-image"><img/></div>
<div class="blocks-gallery-image"><img/></div>
<div class="blocks-gallery-image"><img src="https://cldup.com/uuUqE_dXzy.jpg" alt="title" /></div>
<div class="blocks-gallery-image"><img src="https://cldup.com/uuUqE_dXzy.jpg" alt="title" /></div>
</div>
<!-- /wp:core/gallery -->

0 comments on commit 30e366b

Please sign in to comment.