-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
224 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,25 @@ | ||
hexo.extend.tag.register('image', ([src, title]) => { | ||
function renderImage(src, title) { | ||
return `<figure class="image-bubble"> | ||
<img src="${src}" alt="${title}"> | ||
<div class="img-lightbox"> | ||
<div class="aspect-ratio"> | ||
<div class="placeholder"></div> | ||
<img src="${src}" alt="${title}"> | ||
</div> | ||
</div> | ||
<div class="image-caption">${title}</div> | ||
</figure>` | ||
} | ||
|
||
|
||
hexo.extend.tag.register('image', ([src, title]) => { | ||
return renderImage(src, title) | ||
}) | ||
|
||
hexo.extend.filter.register('before_post_render', data => { | ||
data.content = data.content.replace(/\!\[(.*)\]\((.+)\)/gmi, (match, title, src) => { | ||
const attrs = src.split(' ') | ||
title = title || (attrs[1] && attrs[1].replace(/\"|\'/g, '')) || '未定义' | ||
return `{% image ${attrs[0]} ${title} %}` | ||
}) | ||
return data | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
.img-lightbox { | ||
text-align: center; | ||
.aspect-ratio { | ||
position: relative; | ||
} | ||
|
||
img { | ||
display: inline; | ||
margin: 0; | ||
cursor: pointer; | ||
cursor: -webkit-zoom-in; | ||
&.zoom-img { | ||
cursor: -webkit-zoom-out; | ||
} | ||
} | ||
|
||
.zoom-img, | ||
.zoom-img-wrap { | ||
position: relative; | ||
z-index: 889; | ||
.transition(.3s) | ||
} | ||
.zoom-img-wrap.abs { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
.zoom-overlay { | ||
position: fixed; | ||
z-index: 888; | ||
background: rgba(0, 0, 0, .6); | ||
opacity: 0; | ||
cursor: pointer; | ||
cursor: -webkit-zoom-out; | ||
.transition(.3s); | ||
&.show { | ||
opacity: 1; | ||
+ .zoom-img-title { | ||
opacity: 1; | ||
} | ||
} | ||
} | ||
|
||
.zoom-img-title { | ||
position: fixed; | ||
z-index: 900; | ||
height: 30px; | ||
line-height: 30px; | ||
color: #fff; | ||
background: rgba(0, 0, 0, .3); | ||
opacity: 0; | ||
.transition(.3s); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
71a2be0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
发现的问题1 :
` 内的部分仍然会被渲染,如
渲染为了
问题2:
当画面中只有图片的下半部分时,点击放大失效。
问题3:
浏览器窗口宽度较小,但足够显示图片原图大小时,图片仍会被轻度改变大小,如果图片内容是文字截图的话就会比较明显得看到。同时,页面最下方的标题文字也发虚了。这种情况对于宽度大于高度的图片更易出现。
问题4:
当浏览器窗口高度较小,对于高度大于宽度的图片,画面中只显示其上半部分时,点击放大,半透明遮罩不会出现、最下方的标题文字发虚。
功能建议:
alt
属性渲染成了图片下方标题,是否使用title
属性更好?71a2be0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可能是 chrome 版本的问题,问题2在 57.0 上出现,54.0 上没问题。
71a2be0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
移动端,手指放在图片上滑动页面时,也会触发图片放大,体验不是很好。
71a2be0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
移动端 firefox也有这样的问题