
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
react-image-holder
Advanced tools
An <img /> component for React which can render real images as well use an offline placeholder as a fallback if need be.
All placeholders are rendered using holder.js, meaning they will work even when offline. You can even configure the component to always render a placeholder for all its instances.
$ npm install react-image-holder
## Examples
All examples assume you have require()-d the component:
var Img = require('react-image-holder');
A real image
var realImage = (
<Img src="http://animalia-life.com/data_images/cat/cat5.jpg" />
);
Output:
<img src="http://animalia-life.com/data_images/cat/cat5.jpg" />
Additional attributes
var realImage = (
<Img src="http://animalia-life.com/data_images/cat/cat5.jpg"
width="802"
height="450"
className="cat-photo" />
);
Output:
<img width="802" height="450" class="cat-photo" src="http://animalia-life.com/data_images/cat/cat5.jpg" />
Use a placeholder instead
var realImage = (
<Img src="http://animalia-life.com/data_images/cat/cat5.jpg"
width="802"
height="450"
className="cat-photo"
usePlaceholder={true}
/>
);
Output:
<img class="cat-photo" data-src="holder.js/802x450?auto=true&theme=vine" />
Holder.js then processes the above tag and renders a placeholder.
Setting placeholder properties
var placeholderProps = {
theme: 'blue',
size: 50,
auto: false,
};
var realImage = (
<Img src="http://animalia-life.com/data_images/cat/cat5.jpg"
width="802"
height="450"
usePlaceholder={true}
placeholder={placeholderProps}
/>
);
Output:
<img data-src="holder.js/802x450?auto=false&size=50&theme=blue" />
See holder.js property list for all available properties.
Global placeholders
Rather than passing the usePlaceholder property to each instance of the component you can
also set this property's default value at the start of your app:
Img.DEFAULT_PROPS.usePlaceholder = true;
Now all subsequent instances of the component will automatically use a placeholder image. And you can still override the setting on per-instance basis!
$ npm install
$ npm run build
Contributions are welcome! Please see CONTRIBUTING.md.
MIT - see LICENSE.md
FAQs
React image component with offline placeholder fallbacks
The npm package react-image-holder receives a total of 8 weekly downloads. As such, react-image-holder popularity was classified as not popular.
We found that react-image-holder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.