We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
由于 MIP 规范要求, 不能使用 <img> 标签, 必须使用 <mip-img> 标签: 文档 , 并且需要设置宽高信息.
<img>
<mip-img>
考虑如何在 Hexo 编译时获取图片宽高, 本地图片还好, 远程的如何破?
The text was updated successfully, but these errors were encountered:
@xuexb 还是别编译动态获取了,直接要求用户在使用此模板是,如果需要使用img标签,必须定义宽高属性就行,hexojs 编译时只需读取 <img> 宽高属性值。
hexojs
Sorry, something went wrong.
思路是在页面渲染后 after_render:html ,使用勾子把内容里的 <img> 替换为 <mip-img> ,代码是:
after_render:html
hexo.extend.filter.register('after_render:html',function (html) { return html.replace(/<img([\S\s]+?)\/?>/ig,function (match,tag) { return '<mip-img ${tag}></mip-img>'.replace('${tag}',tag.trim()); }); });
当然也可以做成自动抓取
md5
No branches or pull requests
由于 MIP 规范要求, 不能使用
<img>
标签, 必须使用<mip-img>
标签: 文档 , 并且需要设置宽高信息.考虑如何在 Hexo 编译时获取图片宽高, 本地图片还好, 远程的如何破?
The text was updated successfully, but these errors were encountered: