Skip to content

Commit

Permalink
Gallery Block: Fix inserting a gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Aug 8, 2017
1 parent 03d0804 commit d7033d5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions blocks/library/gallery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const editMediaLibrary = ( attributes, setAttributes ) => {
};

function defaultColumnsNumber( attributes ) {
attributes.images = attributes.images || [];
return Math.min( 3, attributes.images.length );
}

Expand All @@ -68,6 +67,10 @@ registerBlockType( 'core/gallery', {
icon: 'format-gallery',
category: 'common',

defaultAttributes: {
images: [],
},

getEditWrapperProps( attributes ) {
const { align } = attributes;
if ( 'left' === align || 'right' === align || 'wide' === align || 'full' === align ) {
Expand All @@ -76,7 +79,7 @@ registerBlockType( 'core/gallery', {
},

edit( { attributes, setAttributes, focus, className } ) {
const { images = [], columns = defaultColumnsNumber( attributes ), align = 'none' } = attributes;
const { images, columns = defaultColumnsNumber( attributes ), align = 'none' } = attributes;
const setLinkTo = ( value ) => setAttributes( { linkTo: value } );
const setColumnsNumber = ( event ) => setAttributes( { columns: event.target.value } );
const updateAlignment = ( nextAlign ) => setAttributes( { align: nextAlign } );
Expand Down

0 comments on commit d7033d5

Please sign in to comment.