Skip to content

Commit cf6ecac

Browse files
committed
fix: gatsby-plugin-image bug
1 parent dd725ec commit cf6ecac

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

gatsby-browser.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ import './src/styles/main.css';
22

33
// eslint-disable-next-line import/prefer-default-export
44
export const onRouteUpdate = ({ location }) => {
5-
console.log('on route update');
6-
7-
// Find all .gatsby-image-wrapper [data-main-image] elements check if they are are already loaded
8-
// If yes, add the class 'loaded' to the element
9-
// If no, add a listener to the element to add the class 'loaded' when the image is loaded
5+
// TODO: Fix of gatsby-plugin-image bug, that prevents images from being displayed
6+
// It happens because gatsby does not trigger a function that sets to an element opacity: 1
7+
// Bug is very hard to reproduce, it happens only in production builds
108

119
const mainImages = document.querySelectorAll('.gatsby-image-wrapper [data-main-image]');
1210
mainImages.forEach((mainImage) => {

src/styles/global.css

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
}
1010
}
1111

12-
/* TODO: Fix Gatsby bug with images being hidden,the issue is possible to catch only in production build */
13-
/* .gatsby-image-wrapper [data-main-image] {
12+
.gatsby-image-wrapper .loaded[data-main-image] {
1413
opacity: 1 !important;
15-
} */
14+
}

0 commit comments

Comments
 (0)