1- import React , { memo , useEffect , useState } from " react" ;
2- import { getKey } from " ./key" ;
1+ import React , { memo , useEffect , useState } from ' react' ;
2+ import { getKey } from ' ./key' ;
33
4- const baseServiceUrl = " https://service.assetcrush.com" ;
4+ const baseServiceUrl = ' https://service.assetcrush.com' ;
55
66const ImageCrush = ( { url, width, height, ...props } ) => {
7- const [ image , setImage ] = useState ( "" ) ;
8- const key = getKey ( ) ;
9-
10- const imageUrl = `https://service.assetcrush.com?width=${
11- width || "auto"
12- } &height=${ height || "auto" } &original_uri=${ encodeURIComponent ( url ) } `;
7+ const [ image , setImage ] = useState ( '' ) ;
138
149 useEffect ( ( ) => {
1510 if ( ! url ) return ;
1611
17- const _width = width || " auto" ;
18- const _height = height || " auto" ;
12+ const _width = width || ' auto' ;
13+ const _height = height || ' auto' ;
1914 const imageUrl = `${ baseServiceUrl } ?width=${ _width } &height=${ _height } &original_uri=${ encodeURIComponent (
2015 url
2116 ) } `;
2217 const key = getKey ( ) ;
2318
24- fetch ( imageUrl , { headers : { " assetcrush-key" : key } } )
19+ fetch ( imageUrl , { headers : { ' assetcrush-key' : key } } )
2520 . then ( ( r ) => r . blob ( ) )
2621 . then ( ( d ) => {
2722 if ( typeof window === undefined ) return ;
@@ -32,7 +27,7 @@ const ImageCrush = ({ url, width, height, ...props }) => {
3227
3328 if ( ! image ) return null ;
3429
35- return < img src = { image } alt = { "resized" } { ...props } /> ;
30+ return < img src = { image } { ...props } /> ;
3631} ;
3732
3833export default memo ( ImageCrush ) ;
0 commit comments