This repository was archived by the owner on May 4, 2024. It is now read-only.
forked from ottobonn/hexo-image-sizes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (30 loc) · 1.22 KB
/
Copy pathindex.js
File metadata and controls
36 lines (30 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* global hexo */
var assign = require("object-assign");
var ImageSizesProcessor = require("./lib/ImageSizesProcessor");
var imsizeTag = require("./lib/imsize-tag")(hexo);
var debug = require("debug")("hexo:image_sizes");
hexo.config.image_sizes = assign({
pattern: /\.(jpg|jpeg|png)$/i,
profiles: []
}, hexo.config.image_sizes);
debug("Registering for files matching " + hexo.config.image_sizes.pattern);
var profiles = hexo.config.image_sizes.profiles;
Object.keys(profiles).forEach(function registerImageProcessor(profileName) {
var profile = profiles[profileName];
debug(profileName, profile);
var processor = new ImageSizesProcessor(hexo, profileName, {
"width": profile.width,
"height": profile.height,
"allowEnlargement": profile.allowEnlargement
});
hexo.extend.processor.register(hexo.config.image_sizes.pattern, function (file) {
processor.process(file);
});
});
// Set up the "database" of image data (not used yet)
hexo.locals.set("image_sizes_db", [])
// Register the "imsize" tag. These tags interact with the image_sizes_db
hexo.extend.tag.register("imsize", imsizeTag, {ends: true});
hexo.extend.filter.register("after_generate", function() {
debug(hexo.locals.get("image_sizes_db"));
});