@@ -19,23 +19,6 @@ const inImageCache = ({ handle }, shouldCache) => {
1919 return false
2020}
2121
22- // check webp support
23- let isWebpSupportedCache = null
24- const isWebpSupported = ( ) => {
25- if ( isWebpSupportedCache !== null ) {
26- return isWebpSupportedCache
27- }
28-
29- const elem =
30- typeof window !== `undefined` ? window . document . createElement ( `canvas` ) : { }
31- if ( elem . getContext && elem . getContext ( `2d` ) ) {
32- isWebpSupportedCache =
33- elem . toDataURL ( `image/webp` ) . indexOf ( `data:image/webp` ) === 0
34- return isWebpSupportedCache
35- }
36- return false
37- }
38-
3922// Add IntersectionObserver to component
4023const listeners = [ ]
4124let io
@@ -75,16 +58,12 @@ const bgColor = backgroundColor =>
7558const resizeImage = ( { width, height, fit } ) =>
7659 `resize=w:${ width } ,h:${ height } ,fit:${ fit } `
7760
78- const compressAndWebp = webp => `${ webp ? 'output=format:webp/' : '' } compress`
61+ // Filestack supports serving modern formats (like WebP) for supported browsers.
62+ // See: https://www.filestack.com/docs/api/processing/#auto-image-conversion
63+ const compressAndWebp = webp => `${ webp ? 'auto_image/' : '' } compress`
7964
8065const constructURL = ( handle , withWebp , baseURI ) => resize => transforms =>
81- [
82- baseURI ,
83- resize ,
84- ...transforms ,
85- compressAndWebp ( isWebpSupported ( ) && withWebp ) ,
86- handle
87- ] . join ( '/' )
66+ [ baseURI , resize , ...transforms , compressAndWebp ( withWebp ) , handle ] . join ( '/' )
8867
8968// responsiveness transforms
9069const responsiveSizes = size => [
0 commit comments