blueimp/JavaScript-Load-Image

Server side rendering broken with 2.29.0+

cberg-zalando opened this issue · 5 comments

We use the library in a SPA using server side rendering. Due to the implementation of the fix for #97 in js/load-image-orientation.js, the library is broken in this case as the global document object is by default not available on the server.

Thanks for the report @cberg-zalando.

Unfortunately this cannot be lazy loaded, as the check needs to run before any scale() call, which is synchronous.

I'm assuming you're doing isomorphic/universal rendering (including the same JS code on both client/server).
In your use case, would the test code still run on client-side if I add a gating check for the document object?

Yep. It is a React based application and as we are using hydrate for the server side rendering, the created HTML is sent to the client and then the hooks, etc. are created. So I assume it also means that this part will also run in the browser.

I've released blueimp-load-image@4.0.1.
Please let me know if this resolves the issue.

Yep, its working. Thanks for the quick fix.

Thanks for the confirmation. ☺️