把markdown格式的图片解析成图片标签
This commit is contained in:
parent
2e1ecc0237
commit
1c6ce2dae5
|
@ -241,6 +241,8 @@ tag_plugins:
|
|||
# {% image %}
|
||||
image:
|
||||
fancybox: # true, false
|
||||
replace_original: #把markdown格式的图片解析成图片标签
|
||||
enable: false
|
||||
# {% timeline %}
|
||||
timeline:
|
||||
max-height: 80vh
|
||||
|
|
|
@ -2,3 +2,16 @@
|
|||
|
||||
hexo.extend.filter.register('after_render:html', require('./lib/img_lazyload').processSite);
|
||||
hexo.extend.filter.register('after_render:html', require('./lib/img_onerror').processSite);
|
||||
|
||||
function change_image(data){
|
||||
const cfg = this.theme.config.tag_plugins.image.replace_original;
|
||||
|
||||
if (cfg.enable){
|
||||
data.content = data.content.replace(/!\[([^\]]*)]\(([^(]+)\)/g, '{% image $2 $1 %}');
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
hexo.extend.filter.register('before_post_render', change_image, 9);
|
||||
|
|
|
@ -71,7 +71,7 @@ module.exports = ctx => function(args) {
|
|||
if (args.download == 'true') {
|
||||
href = args.src
|
||||
}
|
||||
el += '<a class="image-download blur" style="opacity:0" href="' + href + '"><svg class="icon" style="width: 1em; height: 1em;vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3734"><path d="M561.00682908 685.55838913a111.03077546 111.03077546 0 0 1-106.8895062 0L256.23182837 487.72885783a55.96309219 55.96309219 0 0 1 79.13181253-79.18777574L450.70357448 523.88101491V181.55477937a55.96309219 55.96309219 0 0 1 111.92618438 0v344.06109173l117.07478902-117.07478901a55.96309219 55.96309219 0 0 1 79.13181252 79.18777574zM282.81429711 797.1487951h447.70473912a55.96309219 55.96309219 0 0 1 0 111.92618438H282.81429711a55.96309219 55.96309219 0 0 1 0-111.92618438z" p-id="3735"></path></svg></a>'
|
||||
el += '<a class="image-download blur" style="opacity:0" target="_blank" download="' + args.alt + 'href="' + href + '"><svg class="icon" style="width: 1em; height: 1em;vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3734"><path d="M561.00682908 685.55838913a111.03077546 111.03077546 0 0 1-106.8895062 0L256.23182837 487.72885783a55.96309219 55.96309219 0 0 1 79.13181253-79.18777574L450.70357448 523.88101491V181.55477937a55.96309219 55.96309219 0 0 1 111.92618438 0v344.06109173l117.07478902-117.07478901a55.96309219 55.96309219 0 0 1 79.13181252 79.18777574zM282.81429711 797.1487951h447.70473912a55.96309219 55.96309219 0 0 1 0 111.92618438H282.81429711a55.96309219 55.96309219 0 0 1 0-111.92618438z" p-id="3735"></path></svg></a>'
|
||||
}
|
||||
el += '</div>'
|
||||
|
||||
|
|
Loading…
Reference in New Issue