Skip to content
This repository has been archived by the owner on Nov 7, 2021. It is now read-only.

Commit

Permalink
fix: config bug
Browse files Browse the repository at this point in the history
  • Loading branch information
harbo committed May 7, 2019
1 parent df38d4e commit 79e38bb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions util/image-res-renderer.js
Expand Up @@ -4,7 +4,7 @@ const syncRequest = require('sync-request');
const fs = require('hexo-fs');
const imageCachePath = './img-cache/'

function renderImageResolution(content, title) {
function renderImageResolution(content, title, config) {
var imageMap = new Map()
// 一行一行读取image-size.db内容,不存在就创建之
fs.writeFileSync(path.join(imageCachePath, 'image-size.db'), '', {"flag": 'a+'})
Expand All @@ -15,10 +15,10 @@ function renderImageResolution(content, title) {

let imgTagRegExp_dataOriginal = /(<img src="(.*)" data-original="([^"]*)"[^<]*>)/g
let imgTagRegExp_src = /(<(img) src="([^"]*)"[^<]*>)/g
return content.replace(hexo.config.photoswipe.imgSrcIn === 'dataOriginal' ? imgTagRegExp_dataOriginal : imgTagRegExp_src, function (match, p1, p2, p3, offset, string) {
return content.replace(config.photoswipe.imgSrcIn === 'dataOriginal' ? imgTagRegExp_dataOriginal : imgTagRegExp_src, function (match, p1, p2, p3, offset, string) {
title = title.replace(/[,_:'";?!@><.]/gi, '-').replace(/ /g, '')
var img = p3.replace(/\/.*\/([^"]*)/g, path.join(title, '$1'))
img = path.join(hexo.config.photoswipe.imageFileBaseDir, img)
img = path.join(config.photoswipe.imageFileBaseDir, img)
var imageSize = {}
if (p3.indexOf('http') === 0) {
// 以http开头的data-origianl属性
Expand Down Expand Up @@ -69,7 +69,7 @@ function renderImageResolution(content, title) {
// 本地图片,可以求取大小
imageSize = sizeOf(img)
}
return '<div class="' + hexo.config.photoswipe.className + '" data-type="' + hexo.config.photoswipe.dataType + '" data-size="' + imageSize.width + 'x' + imageSize.height + '">' + p1 + '</div>'
return '<div class="' + config.photoswipe.className + '" data-type="' + config.photoswipe.dataType + '" data-size="' + imageSize.width + 'x' + imageSize.height + '">' + p1 + '</div>'
})
}

Expand Down

0 comments on commit 79e38bb

Please sign in to comment.