Skip to content

Commit

Permalink
Try adjusting deprecated attributes
Browse files Browse the repository at this point in the history
Also re-add the deprecated CSS class.
  • Loading branch information
Joen Asmussen committed Jan 18, 2018
1 parent 3da0798 commit 450f716
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
39 changes: 39 additions & 0 deletions blocks/library/gallery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,45 @@ registerBlockType( 'core/gallery', {

deprecated: [
{
attributes: {
align: {
type: 'string',
default: 'none',
},
images: {
type: 'array',
default: [],
source: 'query',
selector: 'div.wp-block-gallery figure.blocks-gallery-image img',
query: {
url: {
source: 'attribute',
attribute: 'src',
},
alt: {
source: 'attribute',
attribute: 'alt',
default: '',
},
id: {
source: 'attribute',
attribute: 'data-id',
},
},
},
columns: {
type: 'number',
},
imageCrop: {
type: 'boolean',
default: true,
},
linkTo: {
type: 'string',
default: 'none',
},
},

save( { attributes } ) {
const { images, columns = defaultColumnsNumber( attributes ), align, imageCrop, linkTo } = attributes;
return (
Expand Down
5 changes: 5 additions & 0 deletions blocks/library/gallery/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
flex-wrap: wrap;
list-style-type: none;

.blocks-gallery-image,
.blocks-gallery-item {
margin: 8px;
display: flex;
Expand All @@ -26,6 +27,7 @@
}

// Cropped
&.is-cropped .blocks-gallery-image,
&.is-cropped .blocks-gallery-item {
img {
flex: 1;
Expand All @@ -43,16 +45,19 @@
}

// Responsive fallback value, 2 columns
& .blocks-gallery-image,
& .blocks-gallery-item {
width: calc( 100% / 2 - 16px );
}

&.columns-1 .blocks-gallery-image,
&.columns-1 .blocks-gallery-item {
width: calc(100% / 1 - 16px);
}

@include break-small {
@for $i from 3 through 8 {
&.columns-#{ $i } .blocks-gallery-image,
&.columns-#{ $i } .blocks-gallery-item {
width: calc(100% / #{ $i } - 16px );
}
Expand Down

0 comments on commit 450f716

Please sign in to comment.