All Projects → socialtables → React Image Fallback

socialtables / React Image Fallback

stop displaying broken images, have another image to fallback on.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Image Fallback

React Echarts V3
React.js(v16.x+) component wrap for ECharts.js(v3.x+)
Stars: ✭ 48 (-54.72%)
Mutual labels:  library, react-component
Tomo
Tomo is a collection of fast image processing effects for Android
Stars: ✭ 105 (-0.94%)
Mutual labels:  library
Pdfbox
Mirror of Apache PDFBox
Stars: ✭ 1,384 (+1205.66%)
Mutual labels:  library
Javamoney Lib
JavaMoney financial libraries, extending and complementing JSR 354
Stars: ✭ 104 (-1.89%)
Mutual labels:  library
Ts3admin.class
The ts3admin.class is a powerful api for communication with Teamspeak 3 Servers from your website! Your creativity knows no bounds!
Stars: ✭ 103 (-2.83%)
Mutual labels:  library
Bubble Navigation
🎉 [Android Library] A light-weight library to easily make beautiful Navigation Bar with ton of 🎨 customization option.
Stars: ✭ 1,537 (+1350%)
Mutual labels:  library
Charcoal Ios
A modern way to filter things in your iOS apps
Stars: ✭ 102 (-3.77%)
Mutual labels:  library
Tagify
🔖 lightweight, efficient Tags input component in Vanilla JS / React / Angular / Vue
Stars: ✭ 2,305 (+2074.53%)
Mutual labels:  react-component
Central
Hoa is a modular, extensible, and structured set of PHP libraries.
Stars: ✭ 105 (-0.94%)
Mutual labels:  library
Alchemy
A discord library for Elixir
Stars: ✭ 104 (-1.89%)
Mutual labels:  library
Go Execute
Automate CLI commands with Go
Stars: ✭ 104 (-1.89%)
Mutual labels:  library
Simplepie
A simple Atom/RSS parsing library for PHP.
Stars: ✭ 1,389 (+1210.38%)
Mutual labels:  library
Swift Screencapture
A Swift framework to easily capture the screen on OS X.
Stars: ✭ 105 (-0.94%)
Mutual labels:  library
Datepicker
A Date Picker with Calendar for iPhone and iPad Apps.
Stars: ✭ 103 (-2.83%)
Mutual labels:  library
Pluralizador.js
Pluralize Portuguese nouns.
Stars: ✭ 106 (+0%)
Mutual labels:  library
Coq Ext Lib
A library of Coq definitions, theorems, and tactics. [[email protected],@liyishuai]
Stars: ✭ 102 (-3.77%)
Mutual labels:  library
Freeradius Client
A BSD licenced RADIUS client library
Stars: ✭ 103 (-2.83%)
Mutual labels:  library
Pdfviewpager
Android widget that can render PDF documents stored on SD card, linked as assets, or downloaded from a remote URL.
Stars: ✭ 1,508 (+1322.64%)
Mutual labels:  library
Tomorrowland
Lightweight Promises for Swift & Obj-C
Stars: ✭ 106 (+0%)
Mutual labels:  library
Unix Permissions
Swiss Army knife for Unix permissions
Stars: ✭ 106 (+0%)
Mutual labels:  library

React Image Fallback

React Image Fallback exists for those times that you're just not sure an image will be there. See a simple demo here

Circle CI TypeScript definitions on DefinitelyTyped

Install

npm install react-image-fallback

Required Props

src

A string represent the url to your primary image.

fallbackImage

A string representing the image you want to fallback to if your primary image is not there. Optionally this can also be passed in as a react element. This can also be passed in as an array of string srcs or react elements, the component will attempt to keep trying srcs until a loadable src is found. It should be noted that a react element will always be treated as a loadable src.

Optional Props

initialImage

The image to show before your src or fallbackImage load. Can optionally be passed in as a react element.

initialTimeout

timeout in millisecond before to show initialImage. Default is null which should initialImage immediately

onLoad

A callback called if initial image loads successfully, will be called with successful image url.

onError

A callback called if initial image load fails, will be called with failing image url.

spread props

This component also utilizes jsx spread attributes to pass along custom image attributes such as alt tags and className. Only valid dom props will be spread to the image tag.

Use

import React From "react";
import ReactImageFallback from "react-image-fallback";
export default class ShowImage extends React.Component {
	render() {
		return (
			<div>
				<ReactImageFallback
					src="my-image.png"
					fallbackImage="my-backup.png"
					initialImage="loader.gif"
					alt="cool image should be here"
					className="my-image" />
			</div>
		);
	}
}

Copyright (C) 2017 Social Tables, Inc. (https://www.socialtables.com) All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].