{"id":18285407,"url":"https://github.com/lh0x00/rc-image-loader","last_synced_at":"2025-04-05T07:32:17.336Z","repository":{"id":65482639,"uuid":"140650713","full_name":"lh0x00/rc-image-loader","owner":"lh0x00","description":"handle render a preview image is tiny while waiting for real image loading. the real image is lazy-loaded when loaded. support server-side render for seo!","archived":false,"fork":false,"pushed_at":"2020-07-13T22:11:54.000Z","size":43,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T12:58:05.289Z","etag":null,"topics":["background","component","image","lazy-loading","placeholder","react","rendering","seo","server-side-rendering","ssr"],"latest_commit_sha":null,"homepage":"https://codesandbox.io/s/q8vkmqx4vq","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/lh0x00.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-12T02:32:32.000Z","updated_at":"2024-05-11T16:52:20.000Z","dependencies_parsed_at":"2023-01-25T10:45:32.445Z","dependency_job_id":null,"html_url":"https://github.com/lh0x00/rc-image-loader","commit_stats":null,"previous_names":["lamhieu-vk/rc-image-loader"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lh0x00%2Frc-image-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lh0x00%2Frc-image-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lh0x00%2Frc-image-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lh0x00%2Frc-image-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lh0x00","download_url":"https://codeload.github.com/lh0x00/rc-image-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305879,"owners_count":20917201,"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":["background","component","image","lazy-loading","placeholder","react","rendering","seo","server-side-rendering","ssr"],"created_at":"2024-11-05T13:16:35.412Z","updated_at":"2025-04-05T07:32:12.317Z","avatar_url":"https://github.com/lh0x00.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About\n\n[![npm version][npm-version-image]][npm-url]\n[![npm downloads][npm-downloads-image]][npm-url]\n[![github issues][github-issues-image]][github-issues-url]\n[![build status][travis-image]][travis-url]\n\nHandle render a preview image is tiny while waiting for real image loading. the real image is lazy-loaded when loaded. when use package in server-side, image source return is real-image for best seo.\n\n\n# Installation\n\n```bash\n# use npm\n$ npm install rc-image-loader\n\n# or yarn\n$ yarn add rc-image-loader\n```\n\n## CDN\n\n```html\n// unpkg\n\u003cscript src=\"https://unpkg.com/rc-image-loader/dist/rc-image-loader.js\"\u003e\u003c/script\u003e\n\n// jsdelivr\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/rc-image-loader/dist/rc-image-loader.js\"\u003e\u003c/script\u003e\n```\n\n**Note** use CDN in browser, you can call `rcImageLoader` from Window API. it is available at `window.rcImageLoader`\n\n# Usage\n\n[online example](https://codesandbox.io/s/q8vkmqx4vq)\n\n## Child function\n\n```javascript\nimport React from \"react\";\nimport ImageLoader from \"rc-image-loader\";\n\nconst onLoad = data =\u003e console.log(`Loaded image: `, data.src);\n\nconst onError = data =\u003e console.log(`Error image: `, data.loading);\n\nconst App = () =\u003e (\n  \u003cdiv\u003e\n    // simple\n    \u003cImageLoader placeholder=\"tiny-image.jpg\" image=\"real-image.jpg\"\u003e\n      {({ src }) =\u003e (\u003cimg src={src} alt=\"example for rc-image-loader\" /\u003e)}\n    \u003c/ImageLoader\u003e\n\n    // or use with callback\n    \u003cImageLoader placeholder=\"tiny-image.jpg\" image=\"real-image.jpg\" onLoad={onLoad} onError={onError}\u003e\n      {({ src }) =\u003e (\u003cimg src={src} alt=\"example for rc-image-loader\" /\u003e)}\n    \u003c/ImageLoader\u003e\n  \u003c/div\u003e\n);\n\nexport default App;\n```\n\n## Render props\n\n```javascript\nimport React from \"react\";\nimport ImageLoader from \"rc-image-loader\";\n\nconst onLoad = data =\u003e console.log(`Loaded image: `, data.src);\n\nconst onError = data =\u003e console.log(`Error image: `, data.loading);\n\nconst App = () =\u003e (\n  \u003cdiv\u003e\n    \u003cImageLoader\n      placeholder=\"tiny-image.jpg\"\n      image=\"real-image.jpg\"\n      renderComponent={({ src }) =\u003e (\u003cimg src={src} alt=\"render real image\" /\u003e)}\n      renderLoading={({ src }) =\u003e (\u003cimg src={src} alt=\"render tiny image\" /\u003e)}\n      renderError={({ loading }) =\u003e (\u003ctext\u003eFailed when load image: {loading}\u003c/text\u003e)}\n      onLoad={onLoad}\n      onError={onError}\n    /\u003e\n  \u003c/div\u003e\n);\n\nexport default App;\n```\n\n# Documents\n\n## Config\n\n| name           | type    | description                                                                                                            |\n| -------------- | ------- | ---------------------------------------------------------------------------------------------------------------------- |\n| image          | String  | (required) real image source                                                                                           |\n| placeholder    | String  | (required) tiny image source                                                                                           |\n| renderComponent| Func    | (optional) component will render when loaded real image, when use render props. defualt: undefined                     |\n| renderError    | Func    | (optional) component will render have a error load image, when use render props. defualt: undefined                    |\n| renderLoading  | Func    | (optional) component will render when loading real image, when use render props. defualt: undefined                    |\n| onLoaded       | Func    | (optional) function callback when loaded image. default: undefined                                                     |\n| onError        | Func    | (optional) function callback when failed load image. default: undefined                                                |\n\n## Props\n\nvalues return to your components, append to props\n\n| name      | type    | description                                |\n| --------- | ------- | ------------------------------------------ |\n| src       | String  | image source render (tiny or real)         |\n| loading   | String  | image source is loading                    |\n| isError   | Boolean | if have a error when load image            |\n| isLoading | Boolean | if real image is loading                   |\n\n[npm-url]: https://npmjs.org/package/rc-image-loader\n[npm-version-image]: https://badge.fury.io/js/rc-image-loader.svg\n[npm-downloads-image]: https://img.shields.io/npm/dm/rc-image-loader.svg\n[github-issues-image]: https://img.shields.io/github/issues/lamhieu-vk/rc-image-loader.svg\n[github-issues-url]: https://github.com/lamhieu-vk/rc-image-loader/issues\n[travis-image]: https://travis-ci.com/lamhieu-vk/rc-image-loader.svg?branch=master\n[travis-url]: https://travis-ci.com/lamhieu-vk/rc-image-loader?branch=master\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flh0x00%2Frc-image-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flh0x00%2Frc-image-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flh0x00%2Frc-image-loader/lists"}