Skip to content

Commit 47d14be

Browse files
committedMay 4, 2017
fix image
1 parent d6f5e22 commit 47d14be

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed
 

‎index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<script src="js/jquery-ui.min.js"></script>
1313
<script src="js/marked.js"></script>
1414
<script src="js/store.js"></script>
15-
<script src="js/ditto.js"></script>
15+
<script src="js/ditto.js?v=0.2"></script>
1616
<script src="js/prism.js"></script>
1717
</head>
1818
<body>

‎js/ditto.js

+18-11
Original file line numberDiff line numberDiff line change
@@ -254,17 +254,24 @@ function create_page_anchors() {
254254
function normalize_paths() {
255255
// images
256256
$(ditto.content_id + " img").map(function() {
257-
var src = $(this).attr("src").replace("./", "");
258-
if ($(this).attr("src").slice(0, 4) !== "http") {
259-
var pathname = location.pathname.substr(0, location.pathname.length - 1);
260-
var url = location.hash.replace("#", "");
261-
262-
// split and extract base dir
263-
url = url.split("/");
264-
var base_dir = url.slice(0, url.length - 1).toString();
265-
266-
// normalize the path (i.e. make it absolute)
267-
$(this).attr("src", pathname + base_dir + "/" + src);
257+
var src = $(this).attr("src");
258+
if($(this).attr("src").indexOf("../") > -1){
259+
src = $(this).attr("src").replace("../", "");
260+
$(this).attr("src", location.host + "/" + src);
261+
}
262+
else{
263+
src = $(this).attr("src").replace("./", "");
264+
if ($(this).attr("src").slice(0, 4) !== "http") {
265+
var pathname = location.pathname.substr(0, location.pathname.length - 1);
266+
var url = location.hash.replace("#", "");
267+
268+
// split and extract base dir
269+
url = url.split("/");
270+
var base_dir = url.slice(0, url.length - 1).toString();
271+
272+
// normalize the path (i.e. make it absolute)
273+
$(this).attr("src", pathname + base_dir + "/" + src);
274+
}
268275
}
269276
});
270277
}

0 commit comments

Comments
 (0)
Please sign in to comment.