Skip to content

Commit

Permalink
Fix for IE11.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmussen committed Jun 28, 2017
1 parent 653a942 commit 84b6e6f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
14 changes: 13 additions & 1 deletion blocks/library/gallery/gallery-image.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@

export default function GalleryImage( props ) {
if ( ! props.crop ) {
return (
<figure className="blocks-gallery-image">
<img src={ props.img.url } alt={ props.img.alt } />
</figure>
);
}

const croppedImage = {
backgroundImage: 'url(' + props.img.url + ')',
};

return (
<figure className="blocks-gallery-image">
<figure className="blocks-gallery-image" style={ croppedImage }>
<img src={ props.img.url } alt={ props.img.alt } />
</figure>
);
Expand Down
2 changes: 1 addition & 1 deletion blocks/library/gallery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ registerBlockType( 'core/gallery', {
),
<div key="gallery" className={ `blocks-gallery align${ align } columns-${ columns } ${ imageCrop ? 'is-cropped' : '' }` }>
{ images.map( ( img ) => (
<GalleryImage key={ img.url } img={ img } />
<GalleryImage key={ img.url } img={ img } crop={ imageCrop } />
) ) }
</div>,
];
Expand Down
15 changes: 5 additions & 10 deletions blocks/library/gallery/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,13 @@
}
}

// Cropped
// Cropped shows background instead
&.is-cropped .blocks-gallery-image {
img {
width: 100%;
height: 100%;
object-fit: cover;
}
background-position: center center;
background-size: cover;

// IE10+ hack
_:-ms-lang(x), img {
height: auto;
width: auto;
img {
visibility: hidden;
}
}

Expand Down

0 comments on commit 84b6e6f

Please sign in to comment.