Upload pictures to the image server, because the domain name is different, there will be cross-domain issues.
No ' Access-control-allow-origin ' header is present on the requested resource. Origin ' http://img.xxx.com ' is therefore not allowed access.
Look after the code found, cropper.js inside the image reference path to make a judgment, to the IMG tag added crossorigin= "Anonymous" (anonymous cross-domain attribute).
It also uses the XMLHttpRequest GET request to access the IMG reference path, which does not have access. You need to add access-control-allow-origin:* to the image server, or to the request header that is returned, or Access-control-allow-origin: request source domain.
A quick and easy solution is to remove the cross-domain attribute directly from the Cropper.js, because the default slices can also be displayed across domains.
For the lower version of Cropper.js, you can do this:
This. $clone = $clone = $ (' '); $clone. One (' Load ', $.proxy (function () { varNaturalwidth = $clone. Prop (' Naturalwidth ') | |$clone. Width (), Naturalheight= $clone. Prop (' Naturalheight ') | |$clone. Height (); This. Image ={naturalwidth:naturalwidth, naturalheight:naturalheight, Aspectratio:naturalwidth/naturalheight, rotate:0 }; This. url =URL; This. Ready =true; This. Build (); }, This). One (' Error ',function() {$clone. Remove (); }). attr ({//Crossorigin:crossorigin,//"Crossorigin" must before "src" (#271)Src:bustcacheurl | |URL});
It would be nice to comment out that line of Crossorigin.
For the high version (I used the Cropper v2.3.4) because the code is adjusted, find function Getcrossorigin (crossorigin), the line that returns the cross-domain code is commented out, the return of an empty string is good.
That's how I changed it:
function Getcrossorigin (crossorigin) { //return crossorigin? ' crossorigin= ' + crossorigin + ' "': '; return '; }
It can be displayed.
Upload Picture preview control does not show cropper.js cross-domain issues