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

--no commit message

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