{"id":13481559,"url":"https://github.com/FormidableLabs/react-progressive-image","last_synced_at":"2025-03-27T12:31:04.278Z","repository":{"id":47629640,"uuid":"69593600","full_name":"FormidableLabs/react-progressive-image","owner":"FormidableLabs","description":"React component for progressive image loading","archived":true,"fork":false,"pushed_at":"2022-08-19T13:39:23.000Z","size":419,"stargazers_count":733,"open_issues_count":6,"forks_count":61,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-17T19:57:12.210Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FormidableLabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-29T18:00:06.000Z","updated_at":"2025-02-11T15:48:52.000Z","dependencies_parsed_at":"2022-09-06T12:14:35.550Z","dependency_job_id":null,"html_url":"https://github.com/FormidableLabs/react-progressive-image","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FormidableLabs%2Freact-progressive-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FormidableLabs%2Freact-progressive-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FormidableLabs%2Freact-progressive-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FormidableLabs%2Freact-progressive-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FormidableLabs","download_url":"https://codeload.github.com/FormidableLabs/react-progressive-image/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245844853,"owners_count":20681790,"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":[],"created_at":"2024-07-31T17:00:52.785Z","updated_at":"2025-03-27T12:31:03.968Z","avatar_url":"https://github.com/FormidableLabs.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Uncategorized","Components"],"sub_categories":["Uncategorized","Media"],"readme":"# React Progressive Image\n\n[![Maintenance Status][maintenance-image]](#maintenance-status)\n\n[`react-progressive-image`](https://www.npmjs.com/package/react-progressive-image) React component for progressive image loading\n\n### Install\n\n```bash\n$ yarn add react-progressive-image\n```\n\nThe UMD build is also available on [unpkg](https://unpkg.com):\n\n```html\n\u003cscript src=\"https://unpkg.com/react-progressive-image@0.1.0/umd/react-progressive-image.min.js\"\u003e\u003c/script\u003e\n```\n\nIf you use the UMD build you can find the library on `window.ReactProgressiveImage`.\n\n### Examples\n\n#### Simple\n\n```jsx\n\u003cProgressiveImage src=\"large-image.jpg\" placeholder=\"tiny-image.jpg\"\u003e\n  {src =\u003e \u003cimg src={src} alt=\"an image\" /\u003e}\n\u003c/ProgressiveImage\u003e\n```\n\n#### With Delay\n\n```jsx\n\u003cProgressiveImage\n  delay={3000}\n  src=\"large-image.jpg\"\n  placeholder=\"tiny-image.jpg\"\n\u003e\n  {src =\u003e \u003cimg src={src} alt=\"an image\" /\u003e}\n\u003c/ProgressiveImage\u003e\n```\n\n#### With loading argument\n\n```jsx\n\u003cProgressiveImage src=\"large-image.jpg\" placeholder=\"tiny-image.jpg\"\u003e\n  {(src, loading) =\u003e (\n    \u003cimg style={{ opacity: loading ? 0.5 : 1 }} src={src} alt=\"an image\" /\u003e\n  )}\n\u003c/ProgressiveImage\u003e\n```\n\n#### With srcSet\n\n```jsx\n\u003cProgressiveImage\n  src=\"medium.jpg\"\n  srcSetData={{\n    srcSet: 'small.jpg 320w, medium.jpg 700w, large.jpg 2000w',\n    sizes: '(max-width: 2000px) 100vw, 2000px'\n  }}\n  placeholder=\"tiny-image.jpg\"\n\u003e\n  {(src, _loading, srcSetData) =\u003e (\n    \u003cimg\n      src={src}\n      srcSet={srcSetData.srcSet}\n      sizes={srcSetData.sizes}\n      alt=\"an image\"\n    /\u003e\n  )}\n\u003c/ProgressiveImage\u003e\n```\n\n#### Component As Placeholder\n\nIf you want to use a component, such as a loading spinner, as a placeholder, you can make use of the `loading` argument in the render callback. It will be true while the main image is loading and false once it has fully loaded. Keep in mind that the `placeholder` props is `required`, so you will need to explicitly declare an empty string as it's value if you plan on using a component in the render callback.\n\n```jsx\nconst dominantImageColor = '#86356B';\nconst placeholder = (\n  \u003cdiv\n    style={{ backgroundColor: dominantImageColor, height: 300, width: 500 }}\n  /\u003e\n);\n\n\u003cProgressiveImage src=\"large-image.jpg\" placeholder=\"\"\u003e\n  {(src, loading) =\u003e {\n    return loading ? placeholder : \u003cimg src={src} alt=\"an image\" /\u003e;\n  }}\n\u003c/ProgressiveImage\u003e;\n```\n\n#### Progressive Enhancement and No JavaScript\n\nSince this component relies on JavaScript to replace the placeholder src with the full image src, you should use a fallback image if your application supports environments that do not have JavaScript enabled or is progressively enhanced.\n\nYou can do this by adding the fallback image inside of a `\u003cnoscript\u003e` tag in the render callback you provide as the `ProgressiveImage` component's child.\n\n```jsx\n\u003cProgressiveImage src=\"large-image.jpg\" placeholder=\"tiny-image.jpg\"\u003e\n  {src =\u003e {\n    return (\n      \u003cdiv\u003e\n        \u003cimg className=\"progressive-image\" src={src} /\u003e\n        \u003cnoscript\u003e\n          \u003cimg className=\"progressive-image no-script\" src=\"large-image.jpg\" /\u003e\n        \u003c/noscript\u003e\n      \u003c/div\u003e\n    );\n  }}\n\u003c/ProgressiveImage\u003e\n```\n\n### Props\n\n| Name        | Type                                   | Required | Description                                     |\n| ----------- | -------------------------------------- | -------- | ----------------------------------------------- |\n| children    | `function`                             | `true`   | returns `src`, `loading`, and `srcSetData`      |\n| delay       | `number`                               | `false`  | time in milliseconds before src image is loaded |\n| onError     | `function`                             | `false`  | returns error event                             |\n| placeholder | `string`                               | `true`   | the src of the placeholder image                |\n| src         | `string`                               | `true`   | the src of the main image                       |\n| srcSetData  | `{srcSet: \"string\", sizes: \"string\" }` | `false`  | srcset and sizes to be applied to the image     |\n\n## Maintenance Status\n\n**Archived:** This project is no longer maintained by Formidable. We are no longer responding to issues or pull requests unless they relate to security concerns. We encourage interested developers to fork this project and make it their own!\n\n[maintenance-image]: https://img.shields.io/badge/maintenance-archived-red.svg","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFormidableLabs%2Freact-progressive-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFormidableLabs%2Freact-progressive-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFormidableLabs%2Freact-progressive-image/lists"}