jq wordexport 图片显示不全或图片过大问题

问题阐述:

在导出文件时存在图片地址会出现图片过大无法展示全问题,给img设置大下后也不生效

// var img = new Image() for (var i = 0; i < img.length; i++) { // Calculate dimensions of output image var w = 500 // var w = Math.min(img[i].width, options.maxWidth); var h = img[i].height * (w / img[i].width); // Create canvas for converting image to data URL // let canvas = document.createElement("CANVAS"); // canvas.width = w; // canvas.height = h; // var imgId = '#' + img[i].id // img[i].src = img[i].src.replace("https","http") // $(canvas).attr("id", "test_word_img_" + i).width(w).height(h).insertAfter(imgId) // // Draw image to canvas // var context = canvas.getContext('2d'); // context.drawImage(img[i], 0, 0, w, h); // // Get data URL encoding of image // var uri = canvas.toDataURL("image/png"); // console.info('uri', uri) // $(img[i]).attr("src", img[i].src); // img[i].width = w; // img[i].height = h; // // Save encoded image to array // images[i] = { // type: uri.substring(uri.indexOf(":") + 1, uri.indexOf(";")), // encoding: uri.substring(uri.indexOf(";") + 1, uri.indexOf(",")), // location: $(img[i]).attr("src"), // data: uri.substring(uri.indexOf(",") + 1) // }; var img = markup.find('img'); // var img = new Image() for (var i = 0; i < img.length; i++) { // Calculate dimensions of output image var w = 500 // var w = Math.min(img[i].width, options.maxWidth); var h = img[i].height * (w / img[i].width); img[i].width = w img[i].height = h // // Create canvas for converting image to data URL // let canvas = document.createElement("CANVAS"); // canvas.width = w; // canvas.height = h; // var imgId = '#' + img[i].id // img[i].src = img[i].src.replace("https","http") // $(canvas).attr("id", "test_word_img_" + i).width(w).height(h).insertAfter(imgId) // // Draw image to canvas // var context = canvas.getContext('2d'); // context.drawImage(img[i], 0, 0, w, h); // // Get data URL encoding of image // var uri = canvas.toDataURL("image/png"); // console.info('uri', uri) // $(img[i]).attr("src", img[i].src); // img[i].width = w; // img[i].height = h; // // Save encoded image to array // images[i] = { // type: uri.substring(uri.indexOf(":") + 1, uri.indexOf(";")), // encoding: uri.substring(uri.indexOf(";") + 1, uri.indexOf(",")), // location: $(img[i]).attr("src"), // data: uri.substring(uri.indexOf(",") + 1) // };