LoginGraphic: remove image resizing
The previous version was trying to fetch an optimized image with the exact size required, but the URL given was pre-optimized, so it wasn't working correctly. The additional work is also slow (seems to lock up mobile a bit), and since it wasn't functional, just removed it entirely. It will be easier to just pre-reduce the image size to something suitable for a 1080p screen (the most common screen size at the moment).
This commit is contained in:
parent
50cbd9716a
commit
fea13bdc88
1 changed files with 3 additions and 27 deletions
|
@ -1,37 +1,13 @@
|
||||||
// @flow
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { SITE_NAME, LOGIN_IMG_URL } from 'config';
|
import { SITE_NAME, LOGIN_IMG_URL } from 'config';
|
||||||
import { getThumbnailCdnUrl } from 'util/thumbnail';
|
|
||||||
|
|
||||||
function LoginGraphic(props: any) {
|
function LoginGraphic(props: any) {
|
||||||
const [error, setError] = React.useState(false);
|
const alt = __('%SITE_NAME% login', { SITE_NAME });
|
||||||
const [src, setSrc] = React.useState('---');
|
|
||||||
const containerRef = React.useRef<any>();
|
|
||||||
const imgUrl = LOGIN_IMG_URL;
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
if (containerRef.current && containerRef.current.parentElement && containerRef.current.parentElement.offsetWidth) {
|
|
||||||
const newWidth = containerRef.current.parentElement.offsetWidth;
|
|
||||||
|
|
||||||
let newSrc = imgUrl && imgUrl.trim().replace(/^http:\/\//i, 'https://');
|
|
||||||
// @if TARGET='web'
|
|
||||||
// Pass image urls through a compression proxy.
|
|
||||||
newSrc = getThumbnailCdnUrl({ thumbnail: newSrc, width: newWidth, height: newWidth * 2 });
|
|
||||||
// @endif
|
|
||||||
|
|
||||||
setSrc(newSrc);
|
|
||||||
} else {
|
|
||||||
setSrc(imgUrl);
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
if (error || !imgUrl) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="signup-image" ref={containerRef}>
|
<div className="signup-image">
|
||||||
<img alt={__('%SITE_NAME% login', { SITE_NAME })} src={src} onError={() => setError(true)} />
|
<img alt={alt} src={LOGIN_IMG_URL} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue