Cross-origin text Images
After a small change, you need to display the edited information of another website via Rich Text on the client, including some image content.
There are no other display problems, but the photos cannot be normally displayed. They are always broken image styles.
After debugging, it is found that the image display address is always the hosturl + path of another website. Then, it is found that the database only contains path in Rich Text and does not contain hosturl, therefore, the host address of the local website is automatically added to the image.
Therefore, you must add the path address of the image obtained from the local json content to the hosturl of another website.
The specific implementation method is as follows:
Var json = JSON. parse (content. data); var d = json ["Content"]; // match the image (g indicates matching all results. I indicates case-sensitive) var imgReg =/|\/>)/Gi; // match the src property var srcReg =/src = [\ '\ "]? ([^ \ '\ "] *) [\' \"]? /I; var arr = d. match (imgReg); if (arr! = Null) {for (var I = 0; I <arr. length; I ++) {var src = arr [I]. match (srcReg); // obtain the image address if (src [1]) {var resultImg = mnghost + src [1]; // Add the path in the json content to the address of another server. d = d. replace (src [1], resultImg );}}}