{"id":15434547,"url":"https://github.com/paperstrike/hexo-filter-probe-image-size","last_synced_at":"2025-10-08T00:11:42.029Z","repository":{"id":36972320,"uuid":"379037772","full_name":"PaperStrike/hexo-filter-probe-image-size","owner":"PaperStrike","description":"Probe and set image sizes in Hexo web pages","archived":false,"fork":false,"pushed_at":"2023-01-16T05:05:12.000Z","size":250,"stargazers_count":3,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-29T11:18:22.108Z","etag":null,"topics":["hexo-plugin","image-size"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PaperStrike.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-21T19:12:03.000Z","updated_at":"2024-10-03T17:19:12.000Z","dependencies_parsed_at":"2023-01-17T10:15:39.837Z","dependency_job_id":null,"html_url":"https://github.com/PaperStrike/hexo-filter-probe-image-size","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/PaperStrike/hexo-filter-probe-image-size","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaperStrike%2Fhexo-filter-probe-image-size","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaperStrike%2Fhexo-filter-probe-image-size/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaperStrike%2Fhexo-filter-probe-image-size/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaperStrike%2Fhexo-filter-probe-image-size/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PaperStrike","download_url":"https://codeload.github.com/PaperStrike/hexo-filter-probe-image-size/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaperStrike%2Fhexo-filter-probe-image-size/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278867208,"owners_count":26059738,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hexo-plugin","image-size"],"created_at":"2024-10-01T18:39:51.674Z","updated_at":"2025-10-08T00:11:41.999Z","avatar_url":"https://github.com/PaperStrike.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hexo-filter-probe-image-size\n\n[![npm package](https://img.shields.io/npm/v/hexo-filter-probe-image-size)](https://www.npmjs.com/package/hexo-filter-probe-image-size)\n\nProbe and set `width` and `height` to `\u003cimg\u003e` elements.\n\nAs [modern best practice - Optimize Cumulative Layout Shift | web.dev](https://web.dev/optimize-cls/#modern-best-practice) describes, developers should always set the `width` and `height` attributes without units in HTML, and set one of them to `auto` in CSS.\n\nCore: [nodeca/probe-image-size](https://github.com/nodeca/probe-image-size).\n\n---\n\n🐿️ Jump to [Examples](#examples), [Q\u0026A][q-a], or [Contributing Guide][contributing].\n\n## Usage\n\nAvailable configurations and default values. Configure them in Hexo `_config.yml`.\n\n```yaml\n# Probe \u003cimg\u003e sizes and set related attributes.\nprobe_image_size:\n\n  enable: false\n\n  # https://hexo.io/api/filter#Synopsis\n  priority: 10\n\n  # An array containing the rules to resolve an image path.\n  # If an image matches multiple proxy rules, the resolved\n  # paths will be probed in order until one gives a size.\n  proxies:\n\n    # By default, we use the local image that has the same\n    # file name instead of do a real HTTP request to probe.\n    - name: HTTP to local\n\n      # A regex or string used to specify substrings\n      # that are replaced with the specified target string.\n      match: ^(https?:)?//.+/\n\n      # The string that replaces the substring\n      # specified by the match above.\n      target: images/\n```\n\nWhen resolving an image path (usually grabbed from `\u003cimg\u003e`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.\n\nBy 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.\n\nThe whole process won't mutate any original `src` values.\n\n## Examples\n\n### Proxy specific URL\n\nFor files in my own image CDN `https://example/img/`, use `/home/demo/Pictures/`:\n\n```yaml\nprobe_image_size:\n  enable: true\n  proxies:\n    - name: My CDN\n      match: ^https://example/img/\n      target: /home/demo/Pictures/\n```\n\n### Proxy specific files\n\nFor files with a name prefixed by `Primo-`, use `D:/Primo/pics/`:\n\n```yaml\nprobe_image_size:\n  enable: true\n  proxies:\n    - name: El Primo\n      match: ^.+/(?=Primo-[^/]+$)\n      target: D:/Primo/pics/\n```\n\n### Proxy fallbacks\n\nFor files failed to access in previous proxy, use `/a/path/expected/to/contain/all/images/`, and if failed again, use the original path:\n\n```yaml\nprobe_image_size:\n  enable: true\n  proxies:\n    - name: HTTP to local\n      match: ^(https?:)?//.+/\n      target: images/\n    # When proxy above failed to target a parsable image.\n    - name: All images folder\n      match: ^.+/\n      target: /a/path/expected/to/contain/all/images/\n    # When above failed, too.\n    - name: Try Original\n      # Match all, as all paths contain the empty string.\n      match: ''\n      target: ''\n```\n\n### No proxy\n\nUse the original path directly:\n\n```yaml\nprobe_image_size:\n  enable: true\n  proxies: []\n```\n\n### Run later than others\n\n_See [Filter | Hexo](https://hexo.io/api/filter#Synopsis) for filter priority description._\n\nAs 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.\n\n```yaml\nprobe_image_size:\n  enable: true\n  priority: 11\n```\n\nOr manage the order totally on your own.\n\n```yaml\nsome_other_filter_that_also_supports_priority:\n  priority: 11\n\nprobe_image_size:\n  enable: true\n  priority: 12\n```\n\n## [Q\u0026A][q-a]\n\n## [CONTRIBUTING][contributing]\n\n## [LICENSE](LICENSE)\n\n[q-a]: https://github.com/PaperStrike/hexo-filter-probe-image-size/discussions/categories/q-a\n[contributing]: https://github.com/PaperStrike/hexo-filter-probe-image-size/blob/main/.github/CONTRIBUTING.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaperstrike%2Fhexo-filter-probe-image-size","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaperstrike%2Fhexo-filter-probe-image-size","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaperstrike%2Fhexo-filter-probe-image-size/lists"}