Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is failure in the Mobile browser #20

Closed
alun-430 opened this issue Apr 26, 2019 · 4 comments
Closed

It is failure in the Mobile browser #20

alun-430 opened this issue Apr 26, 2019 · 4 comments

Comments

@alun-430
Copy link

alun-430 commented Apr 26, 2019

Hi, it is no problem in the Google browser.But it has problem in the Mobile browser.
And it tips: ''error: DOMException" and i get the color is white.
Info: In React.
Code:
` imgRef = (e) => {
this.imgDom = e
};

handleImageLoaded = () => {
let that=this;
if(this.imgDom){
const fac = new FastAverageColor();
fac.getColorAsync(this.imgDom, function (color) {
that.setState({
bodyBgColor: color,
});
});
}
};

this.imgRef(e)} src={"https://n1-q.mafengwo.net/s13/M00/1D/C3/wKgEaVyhw-OARMlZAAHft8LZYM070.jpeg?imageMogr2%2Fthumbnail%2F%21750x750r%2Fstrip%2Fquality%2F90"} alt="" />
`
@hcodes
Copy link
Collaborator

hcodes commented Apr 26, 2019

Added in README.md Storing an image from a foreign origin.

@hcodes
Copy link
Collaborator

hcodes commented Apr 27, 2019

Problem solved?

@alun-430
Copy link
Author

alun-430 commented Apr 28, 2019

Problem solved?

Hi, thank you for your solution and solution address.
I added "crossOrigin={'anonymous'}" in <img />, the problem was solved in the Mobile browser.
The sample code:

<img
    ref={this.imgRef}
    src={"https://n1-q.mafengwo.net/s13/M00/1D/C3/wKgEaVyhw-OARMlZAAHft8LZYM070.jpeg? 
    imageMogr2%2Fthumbnail%2F%21750x750r%2Fstrip%2Fquality%2F90"}
    alt=""
    crossOrigin={"anonymous"}
    onLoad={this.handleImageLoaded.bind(this)}
/>

@hcodes
Copy link
Collaborator

hcodes commented Apr 28, 2019

👍

@hcodes hcodes closed this as completed Apr 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants