Skip to content

Hexo JS Advanced Image Optimizer Plugin

Hexo JS Advanced Image Optimizer Plugin

Published on

Tech Used

Hexo JS

Tags

NPM JS Documentation GitHub

The Hexo JS Advanced Image Optimizer Plugin enhances your Hexo JS site by leveraging the power of wsrv.nl, a high-performance image cache and resize service. Powered by Cloudflare’s CDN, it delivers images from over 300 global datacenters, ensuring lightning-fast load times and optimal performance. With support for advanced image processing using technologies like nginx and libvips, this plugin transforms and optimizes images on-the-fly. It’s open-source, free to use, and seamlessly integrates with Hexo JS to process markdown images, cover images, CSS background images, and <object> tags.

Installation

Run the (any) following command in your Hexo project directory to install the plugin:

bun add hexo-adv-img-optimizer --save

Usage

After installing the plugin, all image urls will be converted to CDN urls automatically. For example:

#Example:
https://website.com/image.png -> //images.weserv.nl/?url=https://website.com/image.png
/image.png                    -> //images.weserv.nl/?url=https://website.com/image.png

where https://website.com is the url of your blog that you set in _config.yml.

Configuration

The plugin can be configured globally in Hexo’s _config.yml file under the cdn section or per post using front-matter in Markdown files. Front-matter settings override global settings for specific posts.

  1. Open your Hexo project’s _config.yml file.
  2. Add a cdn section to configure global settings (see Configuration below). Example:
cdn:
  cdn_server: //wsrv.nl
  use_webp: true
  max_width: [1920, 1200, 800, 400]

Global Configuration (_config.yml)

Add a cdn section to _config.yml to set default options for all images. All options are optional, and defaults are applied when not specified.

cdn:
  cdn_server: //wsrv.nl
  native: false
  use_webp: true
  max_width: 1200
  filename: default-image
  brightness: 0
  quality: 75
  fit: cover
  .
  .
  .

Per-Post Configuration (Front-Matter)

Add a cdn section to a post’s front-matter to override global settings for that post’s images (e.g., cover image, markdown images, background images). For example:

---
title: My Post
cdn:
  brightness: 20
  filename: post-specific-image
  quality: 80
  fit: contain
  .
  .
  .
---

📀 Full Available Configuration Options

This page is getting way too longer so visit below link for full configration options.

Please Visit: https://git.hsinghhira.me/hexo-adv-img-optimizer/

Notes

Troubleshooting

For additional help or feature requests, please open an issue on the plugin’s repository or contact the maintainer.

Special Thanks


Share this post on:

Previous Project
Meme Creator - PHP Based
Next Project
Simple CMS