diff --git a/themes/chameleon/scripts/image.js b/themes/chameleon/scripts/image.js
index 5673879..bf43959 100644
--- a/themes/chameleon/scripts/image.js
+++ b/themes/chameleon/scripts/image.js
@@ -6,58 +6,59 @@
* https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images
* Image is resized on-the-fly using Statically Imgpx
* https://statically.io/imgpx
-* Usage: {% image 'folder/filename.jpg' 'description' %}
+* Usage: ![alt](/path/to/img "title")
*/
-hexo.extend.tag.register('image', (args) => {
- let [fileName, alt] = args
- if (!alt) alt = ''
- let modern = fileName
- let legacy = fileName
- // /img/ is a reverse proxy of Statically CDN
- // See source/_redirects
- const link = '/img/'
+hexo.extend.filter.register('marked:renderer', (renderer) => {
+ renderer.image = (href, title, alt) => {
+ if (!alt) alt = ''
+ if (!title) title = alt
+ let modern = href
+ let legacy = href
+ // /img/ is a reverse proxy to Statically CDN
+ // See source/_redirects
+ const link = '/img/'
- if (fileName.endsWith('.png') || fileName.endsWith('.jpg')) {
- modern = fileName.concat('?format=webp')
- } else if (fileName.endsWith('.webp')) {
- // Statically has yet to support animated webp
- // https://github.com/marsble/statically/issues/36
- // modern = fileName.concat('?auto_format=false')
- modern = fileName.replace(/\.webp$/, '.gif')
- legacy = fileName.replace(/\.webp$/, '.gif')
- }
+ if (href.endsWith('.png') || href.endsWith('.jpg')) {
+ modern = href.concat('?format=webp')
+ } else if (href.endsWith('.webp')) {
+ // Statically has yet to support animated webp
+ // https://github.com/marsble/statically/issues/36
+ // modern = href.concat('?auto_format=false')
+ modern = href.replace(/\.webp$/, '.gif')
+ legacy = href.replace(/\.webp$/, '.gif')
+ }
- const modernLink = link + modern
- const legacyLink = link + legacy
+ const modernLink = link + modern
+ const legacyLink = link + legacy
- const img = ``
+ const img = ``
- if (fileName.endsWith('.png') || fileName.endsWith('.webp')) {
- return `
- `
- } else {
- return `${img}`
+ if (href.endsWith('.png') || href.endsWith('.webp')) {
+ return `` +
+ ''
+ } else {
+ return `${img}`
+ }
}
})