{"id":28502380,"url":"https://github.com/hexojs/hexo-filter-lqip","last_synced_at":"2025-07-05T11:31:59.816Z","repository":{"id":32039513,"uuid":"129958624","full_name":"hexojs/hexo-filter-lqip","owner":"hexojs","description":"A Hexo plugins which helps to introduce low quality image placeholders to the theme","archived":false,"fork":false,"pushed_at":"2024-01-07T20:01:11.000Z","size":14420,"stargazers_count":20,"open_issues_count":11,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-06-27T19:12:48.849Z","etag":null,"topics":["hexo","hexo-plugin","image-processing","placeholder","potrace"],"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/hexojs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-04-17T20:04:56.000Z","updated_at":"2024-11-05T19:03:52.000Z","dependencies_parsed_at":"2024-01-23T21:30:43.730Z","dependency_job_id":"83dc1252-b092-4039-a762-60745d3924d3","html_url":"https://github.com/hexojs/hexo-filter-lqip","commit_stats":{"total_commits":163,"total_committers":11,"mean_commits":"14.818181818181818","dds":0.6196319018404908,"last_synced_commit":"59efa7df6c9b874d30ca0766d8a2d07ed8c3133e"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/hexojs/hexo-filter-lqip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexojs%2Fhexo-filter-lqip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexojs%2Fhexo-filter-lqip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexojs%2Fhexo-filter-lqip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexojs%2Fhexo-filter-lqip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hexojs","download_url":"https://codeload.github.com/hexojs/hexo-filter-lqip/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexojs%2Fhexo-filter-lqip/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262888991,"owners_count":23380136,"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","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","hexo-plugin","image-processing","placeholder","potrace"],"created_at":"2025-06-08T16:09:53.251Z","updated_at":"2025-07-05T11:31:59.811Z","avatar_url":"https://github.com/hexojs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hexo-filter-lqip\nA Hexo plugins which helps to introduce low quality image placeholders to the theme\n\n![](https://github.com/ertrzyiks/hexo-filter-lqip/raw/master/preview.gif)\n\n## Installation\n\n```\nnpm i hexo-filter-lqip --save\n```\n\n## Usage\n\nInstall this plugin for the theme and use the view helper to render a placeholder.\n\n\n### lqipFor view helper\n\n```js\nlqipFor(path_to_asset, options)\n```\n\n - **String** *path_to_asset - a path to the image\n - **Object** *options*\n   - **String** *[type]* - a type of placeholder, see the list of [available types](#available-types), defaults to the `default_type` as configured\n\nReturns a CSS value for `background-image` property, which is a simplified version of the original image.\n\nExample for EJS\n\n```ejs\n\u003cdiv\n  style=\"background-image: \u003c%- lqip_for('/content/my-photo.jpg') %\u003e\"\n\u003e\u003c/div\u003e\n```\n\n### Front-end integration\n\nTo make it work as a real placeholder, there must be a piece of JavaScript code, which will eventually replace the placeholder\nwith the original image. It can be done by adding a data attribute with the original image path:\n\n```ejs\n\u003cdiv\n  style=\"background-image: \u003c%- lqip_for('/content/my-photo.jpg') %\u003e\"\n  data-lazy-src=\"/content/my-photo.jpg\"\n\u003e\u003c/div\u003e\n```\n\nand replacing the `background-image` CSS property with the original image once it's loaded:\n\n```js\n(function () {\n  var lazyImages = document.querySelectorAll('[data-lazy-src]')\n\n  lazyImages.forEach(function (img) {\n    var url = img.dataset.lazySrc\n    var image = new Image()\n    image.onload = function () {\n      img.style.backgroundImage = 'url(' + url + ')'\n    }\n    image.src = url\n  })\n})()\n```\n\nFor even more improvement, the script could load only images that are visible on the screen.\n\n## Available types\n\n### Potrace\n\nType name: `potrace`\n\nUses the `posterize` function from [potrace][node-potrace] to generate simplified SVG version of the image. The output\nis optimized with [SVGO][svgo] and inlined.\n\n### Color\n\nType name: `color`\n\nPlain background, the dominant color extracted from the image.\n\n## Configuration\n\nPut your configuration in the theme `_config.yml` under `lqip` key.\nYou can also use the [overriding theme config][1]\nfeature of Hexo. Available options are the following:\n\n#### cache\n\nDefaults to 'lqip-cache.json'. Could be a string with a file name of the cache.\nYou can also set to `false` to disable caching.\n\nIdeally, the cache file should not be checked in into repository.\n\n#### priority\n\nThe priority of the `after_generate` filter. Defaults to 10.\nYou can find more information about priority in [Filter](https://hexo.io/api/filter.html) documentation.\n\n#### default_type\n\nDefaults to `potrace`. Use this type if not specified as a param to `lqip_for` helper.\n\n#### potrace\n\nConfiguration specific to `potrace` type. All keys except `canvas_size` are passed to the `posterize` function of [potrace][node-potrace]\n\n##### canvas_size: {width:, height:}\nBefore the image is passed to potrace, it's resized to this size.\n\n#### Example configuration:\n\n```yml\nlqip:\n  default_type: potrace\n  potrace:\n    canvas_size:\n      width: 140\n    steps: 2\n    color: '#dedede'\n    background: transparent\n```\n\n## Debugging\n\nIf something goes wrong, use `--debug` option to get all information about the generating of the blog and extra\ninformation about low-quality image placeholders processing.\n\n```\nhexo generate --debug\n```\n\nAfter changing parameters of placeholder it may be required to clean cache, by removing the cache file manually or with:\n```\nhexo clean\n```\n\n## Example project\n\nYou can see it put together in the [hexo-lqip-example][2] repository.\n\n## Out there in the wild\n\n- [ertrzyiks's blog](https://blog.ertrzyiks.me)\n- [yummy food blog (in Polish)](https://github.com/ertrzyiks/yummy/tree/hexo)\n\n## Inspirations\n\n- [Using SVG as placeholders ](https://jmperezperez.com/svg-placeholders/)\n- [Willian Justen](https://unsplash.com/@willianjusten) pictures used for the demo\n\n[1]: https://hexo.io/docs/configuration.html#Overriding-Theme-Config\n[2]: https://github.com/ertrzyiks/hexo-lqip-example\n[node-potrace]: https://github.com/Iwasawafag/node-potrace\n[svgo]: https://github.com/svg/svgo\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexojs%2Fhexo-filter-lqip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhexojs%2Fhexo-filter-lqip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexojs%2Fhexo-filter-lqip/lists"}