Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-photo-gallery

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-photo-gallery

Responsive React Photo Gallery Component

  • 5.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19K
increased by18.3%
Maintainers
1
Weekly downloads
 
Created
Source

Join the chat at https://gitter.im/react-photo-gallery/Lobby

A stateless responsive React photo gallery component that maintains the original aspect ratio of your photos and scales them responsively. Add your own routing, lightbox, and manage your own state.

Installation

To install:

npm install --save react-photo-gallery

Demo

http://neptunian.github.io/react-photo-gallery/

To build the examples locally, run:

npm install
npm start

Then open localhost:8000 in a browser.

Use

import React from 'react';
import Gallery from 'react-photo-gallery';

export default class Sample extends React.Component {
    render() {
	return (
	    <Gallery photos={PHOTO_SET} onClickPhoto={this.openLightbox}/>
	);
    }
}
const PHOTO_SET = [
  {
    src: 'http://example.com/example/img1.jpg',
    srcset: [
      'http://example.com/example/img1_1024.jpg 1024w',
      'http://example.com/example/img1_800.jpg 800w',
      'http://example.com/example/img1_500.jpg 500w',
      'http://example.com/example/img1_320.jpg 320w',
    ],
    width: 681,
    height: 1024,
    caption: 'image 1',
  },
  {
    src: 'http://example.com/example/img2.jpg',
    srcset: [
      'http://example.com/example/img2_1024.jpg 1024w',
      'http://example.com/example/img2_800.jpg 800w',
      'http://example.com/example/img2_500.jpg 500w',
      'http://example.com/example/img2_320.jpg 320w',
    ],
    width: 600,
    height: 600,
    caption: 'image 2',
  }
];

PropertyTypeDefaultDescription
photosarrayundefinedrequired; array of objects
colsnumber3optional; number of photos per row
onClickPhotofunctionundefinedoptional; do something when the user clicks a photo

Gallery.photos properties

PropertyTypeDefaultDescription
srcstringundefinedrequired; the src value of the gallery image
widthnumberundefinedrequired; original width of the gallery image (only used for calculating aspect ratio)
heightnumberundefinedrequired; original height of the gallery image (only used for calculating aspect ratio)

Demo explanation

This component uses React Images for lightbox functionality in the example demo, but the component itself does not depend on it. PHOTO_SET obj in the example above is also being passed to lightbox which uses src, srcset, and caption props.

Keywords

FAQs

Package last updated on 28 Feb 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc