提交 dc829525 authored 作者: renjiancai's avatar renjiancai

--no commit message

上级 12a96e7e
...@@ -564,33 +564,35 @@ public class EpubResolve { ...@@ -564,33 +564,35 @@ public class EpubResolve {
int c = 0; int c = 0;
private ArticleLibrary setContentCommInfo(ArticleLibrary content, Ebook ebook, Elements label) { private ArticleLibrary setContentCommInfo(ArticleLibrary content, Ebook ebook, Elements label) {
// 图书相关信息
//content.setBookName(ebook.getName());
content.setBookId(ebook.getId());
// 替换图片资源的href
// book路径
String bookPath = ebook.getEpubFile().substring(0, ebook.getEpubFile().lastIndexOf("/") + 1);
Elements imgs = label.select("img"); // 图书相关信息
String oldImg = ""; // content.setBookName(ebook.getName());
String newImg = ""; content.setBookId(ebook.getId());
if (imgs.size() != 0) {
for (Element img : imgs) { // 替换图片资源的href
String imgSrc = img.attr("src"); // book路径
String bookPath = ebook.getEpubFile();
// 原图片资源路径
oldImg = img.toString(); Elements imgs = label.select("img");
// 修改替换图片路径 String oldImg = "";
if (!imgSrc.contains("/resource")) { String newImg = "";
img.attr("src", bookPath + imgSrc); if (imgs.size() != 0) {
// 新的图片资源路径 for (Element img : imgs) {
newImg = img.toString(); String imgSrc = img.attr("src");
content.setText(content.getText().replace(oldImg, newImg));
// 原图片资源路径
oldImg = img.toString();
// 修改替换图片路径
img.attr("src", "/" + bookPath + "/" + imgSrc);
// 新的图片资源路径
newImg = img.toString();
content.setText(content.getText().replace(oldImg, newImg));
}
} }
}
}
return content; return content;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论