npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

hexo-filter-probe-image-size

v0.4.3

Published

Probe and set image sizes in hexo web pages

Readme

hexo-filter-probe-image-size

npm package

Probe and set width and height to <img> elements.

As modern best practice - Optimize Cumulative Layout Shift | web.dev describes, developers should always set the width and height attributes without units in HTML, and set one of them to auto in CSS.

Core: nodeca/probe-image-size.


🐿️ Jump to Examples, Q&A, or Contributing Guide.

Usage

Available configurations and default values. Configure them in Hexo _config.yml.

# Probe <img> sizes and set related attributes.
probe_image_size:

  enable: false

  # https://hexo.io/api/filter#Synopsis
  priority: 10

  # An array containing the rules to resolve an image path.
  # If an image matches multiple proxy rules, the resolved
  # paths will be probed in order until one gives a size.
  proxies:

    # By default, we use the local image that has the same
    # file name instead of do a real HTTP request to probe.
    - name: HTTP to local

      # A regex or string used to specify substrings
      # that are replaced with the specified target string.
      match: ^(https?:)?//.+/

      # The string that replaces the substring
      # specified by the match above.
      target: images/

When resolving an image path (usually grabbed from <img>s' src attributes), this filter firstly checks if the path matches ^(https?:)?//. If not, will format it to a relative path that has no query string.

By using proxies, you can resolve these possibly formatted paths back to absolute paths. Proxy-resolved absolute paths represent files from the file system. E.g., /home/foo/Pictures/ does represent /home/foo/Pictures/ on POSIX, and D:/home/foo/Pictures/ on Windows (assume you run Hexo in D:), instead of the one based on the generating folder.

The whole process won't mutate any original src values.

Examples

Proxy specific URL

For files in my own image CDN https://example/img/, use /home/demo/Pictures/:

probe_image_size:
  enable: true
  proxies:
    - name: My CDN
      match: ^https://example/img/
      target: /home/demo/Pictures/

Proxy specific files

For files with a name prefixed by Primo-, use D:/Primo/pics/:

probe_image_size:
  enable: true
  proxies:
    - name: El Primo
      match: ^.+/(?=Primo-[^/]+$)
      target: D:/Primo/pics/

Proxy fallbacks

For files failed to access in previous proxy, use /a/path/expected/to/contain/all/images/, and if failed again, use the original path:

probe_image_size:
  enable: true
  proxies:
    - name: HTTP to local
      match: ^(https?:)?//.+/
      target: images/
    # When proxy above failed to target a parsable image.
    - name: All images folder
      match: ^.+/
      target: /a/path/expected/to/contain/all/images/
    # When above failed, too.
    - name: Try Original
      # Match all, as all paths contain the empty string.
      match: ''
      target: ''

No proxy

Use the original path directly:

probe_image_size:
  enable: true
  proxies: []

Run later than others

See Filter | Hexo for filter priority description.

As most of Hexo filters use a priority of 10, setting it to 9 or 11 makes our probe process runs earlier or later than them.

probe_image_size:
  enable: true
  priority: 11

Or manage the order totally on your own.

some_other_filter_that_also_supports_priority:
  priority: 11

probe_image_size:
  enable: true
  priority: 12

Q&A

CONTRIBUTING

LICENSE