| 1234567891011121314151617 |
- import PropTypes from "prop-types";
- import ReactImgix from "react-imgix";
- const Imgix = ({ src,alt="",className="lazyload", ...props}) => {
- if (props.width!=null){
- let devicePixelRatio=window.devicePixelRatio;
- if (devicePixelRatio<1)devicePixelRatio=1;
- props.width=Math.ceil(props.width/devicePixelRatio);
- }
- return (
- <ReactImgix className={className} src={src} alt={alt} {...props}></ReactImgix>
- )
- }
- Imgix.propTypes = {
- src:PropTypes.string.isRequired
- }
- export default Imgix
|