All Projects → henrygd → Bigpicture

henrygd / Bigpicture

Licence: mit
Lightweight JavaScript image / video viewer. Supports Youtube, Vimeo, etc.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Bigpicture

Lightgallery
A customizable, modular, responsive, lightbox gallery plugin.
Stars: ✭ 4,829 (+568.84%)
Mutual labels:  vimeo, youtube, lightbox
Lightgallery.js
Full featured JavaScript image & video gallery. No dependencies
Stars: ✭ 5,168 (+615.79%)
Mutual labels:  vimeo, youtube, lightbox
SharpGrabber
Download from YouTube, Vimeo, PornHub, HLS (M3U8 files) with .NET and JavaScript, Library and desktop app for downloading high quality media
Stars: ✭ 138 (-80.89%)
Mutual labels:  youtube, vimeo
php-video-url-parser
A Simple and efficient PHP Video URL Parser that provides you thumbnails and embed codes for various video streaming websites
Stars: ✭ 57 (-92.11%)
Mutual labels:  youtube, vimeo
Plyr
A simple HTML5, YouTube and Vimeo player
Stars: ✭ 20,859 (+2789.06%)
Mutual labels:  vimeo, youtube
Superembed.js
Fluid width for YouTube, Vimeo, Vine, VideoPress, DailyMotion, and more embedded videos.
Stars: ✭ 615 (-14.82%)
Mutual labels:  vimeo, youtube
React Plyr
📺 A React video component based on Plyr
Stars: ✭ 254 (-64.82%)
Mutual labels:  vimeo, youtube
Openwhyd
💎 Like Pinterest, for Music
Stars: ✭ 287 (-60.25%)
Mutual labels:  vimeo, youtube
Min Vid
Popout video player in Firefox
Stars: ✭ 180 (-75.07%)
Mutual labels:  vimeo, youtube
Ngx Gallery
Angular Gallery, Carousel and Lightbox
Stars: ✭ 417 (-42.24%)
Mutual labels:  youtube, lightbox
React Player
A React component for playing a variety of URLs, including file paths, YouTube, Facebook, Twitch, SoundCloud, Streamable, Vimeo, Wistia and DailyMotion
Stars: ✭ 5,931 (+721.47%)
Mutual labels:  vimeo, youtube
Rssbox
📰 I consume the world via RSS feeds, and this is my attempt to keep it that way.
Stars: ✭ 492 (-31.86%)
Mutual labels:  vimeo, youtube
Lazyframe
🛀🏽 Dependency-free library for lazyloading iframes
Stars: ✭ 237 (-67.17%)
Mutual labels:  vimeo, youtube
laravel-video-api
Laravel (Youtube/Vimeo) Video Data API
Stars: ✭ 53 (-92.66%)
Mutual labels:  youtube, vimeo
Modal Video
Stars: ✭ 224 (-68.98%)
Mutual labels:  vimeo, youtube
Embera
A Oembed consumer library, that gives you information about urls. It helps you replace urls to youtube or vimeo for example, with their html embed code. It has advanced features like offline support, responsive embeds and caching support.
Stars: ✭ 268 (-62.88%)
Mutual labels:  vimeo, youtube
Alltube
Web GUI for youtube-dl
Stars: ✭ 1,925 (+166.62%)
Mutual labels:  vimeo, youtube
Workflowshare
Workflow实例分享
Stars: ✭ 137 (-81.02%)
Mutual labels:  vimeo, youtube
Sonatamediabundle
Symfony SonataMediaBundle
Stars: ✭ 415 (-42.52%)
Mutual labels:  vimeo, youtube
Pylivestream
Pure Python FFmpeg-based live video / audio streaming to YouTube, Facebook, Periscope, Twitch, and more
Stars: ✭ 442 (-38.78%)
Mutual labels:  vimeo, youtube

logo BigPicture.js npm File Size

Example page screenshot

Vanilla JavaScript image / video viewer. Doesn't sit on the DOM when inactive.

Check out the example page here

Installation

Install via package manager or add a script from the dist directory to your page. CDN links are available via jsDelivr.

npm install bigpicture
// import
import BigPicture from 'bigpicture'

// or require
var BigPicture = require('bigpicture')

Or with a script tag:

<script src="BigPicture.js"></script>

No additional CSS file is neccesary.

Usage

When you want to open something, pass an object to BigPicture containing the element from which you want the animation to start, and other optional parameters depending on what you want to do. Examples below use e.target to refer to the trigger element being interacted with in the context of an event handler. You can use a different element if you want (for example, different buttons could be set up to open videos from the same central showcase element).

If your trigger element is an image or an element with a background image, you can open it directly by passing only el.

Options

BigPicture({
	// element from which animation starts (required)
	el: e.target,
	// image url
	imgSrc: 'https://yourimage.jpg',
	// video src (String) or sources (Array)
	vidSrc: ['https://yourvideo.mp4', 'https://yourvideo.webm'],
	// iframe embed URL
	iframeSrc: 'https://youriframe.html',
	// vimeo ID
	vimeoSrc: '119287310',
	// youtube ID
	ytSrc: 'z_PeaHVcohg',
	// use youtube-nocookie
	ytNoCookie: false,
	// audio URL
	audio: 'https://youraudio.mp3',
	// see below for more gallery options
	gallery: '#image_container',
	// attribute used to find gallery elements
	galleryAttribute: 'data-bp',
	// set custom dimensions for embeds / videos
	dimensions: [1920, 1080],
	// show or hide default loading indicator
	noLoader: false,
	// open animation callback
	animationStart: () => {},
	// open animation callback
	animationEnd: () => {},
	// close callback
	onClose: () => {},
	// gallery image change callback
	onChangeImage: () => {},
})

Assign to variable for more control

var bp = BigPicture({...})

// close
bp.close()

// next gallery image
bp.next()

// previous gallery image
bp.prev()

Remote video file

Multiple sources supported as of 1.4.0

BigPicture({
	el: e.target,
	vidSrc: 'https://yourvideo.mp4',
	// or with multiple sources
	// vidSrc: ['https://yourvideo.mp4', 'https://yourvideo.webm']
})

Youtube

Pass in the video ID from the url. For example, the ID for https://www.youtube.com/watch?v=z_PeaHVcohg would be z_PeaHVcohg (The v parameter in the address).

BigPicture({
	el: e.target,
	ytSrc: 'z_PeaHVcohg',
})

Vimeo

Like Youtube, pass in the video ID from the url. The ID for https://vimeo.com/119287310 would be 119287310.

BigPicture({
	el: e.target,
	vimeoSrc: '119287310',
})

iframe embed

Pass in the URL from the iframe.

BigPicture({
	el: e.target,
	iframeSrc: 'https://youriframe.html',
})

Audio

BigPicture({
	el: e.target,
	audio: 'https://youraudio.mp3',
})

Remote individual image

BigPicture({
	el: e.target,
	imgSrc: 'https://yourimage.jpg',
})

Galleries

Add a data-bp attribute to your elements with the image you want to open, and pass a selector string or NodeList to the function. The string should specify a container which has data-bp elements somewhere inside, whereas the NodeList should be the elements themselves.

The attribute name can be overridden with the galleryAttribute option as of 2.4.0. For instance, galleryAttribute: 'src' would open the thumbs in the example below, and the data-bp attributes would be unnecessary.

<div id="image_container">
	<img src="photo1_thumb.jpg" data-bp="photo1.jpg" class="example" />
	<img src="photo2_thumb.jpg" data-bp="photo2.jpg" />
	<img src="photo3_thumb.jpg" data-bp="photo3.jpg" class="example" />
</div>
// opens gallery w/ all three images
BigPicture({
	el: e.target,
	gallery: '#image_container',
})
// opens gallery w/ the two images matching the selector
BigPicture({
	el: e.target,
	gallery: document.querySelectorAll('#image_container .example'),
})

Alternatively, you can pass in an array of objects. The gallery will go through these in order. Here's example code for the unsplash gallery on the demo site:

var unsplashImages = ['meiying', 'clemono2', 'heftiba'].map(function (user) {
	return {
		src: 'https://source.unsplash.com/user/' + user + '/daily',
		// caption: 'This image is from unsplash'
	}
})
BigPicture({
	el: e.target,
	gallery: unsplashImages,
	// optionally specify a starting index
	position: 2,
})

You can also loop the gallery (next on last image gives you the first image, and vice versa).

BigPicture({
	el: e.target,
	gallery: '#image_container',
	loop: true,
})

Captions

To display a caption, add a data-caption attribute with the desired text or HTML to the trigger element itself.

<img src="yourimage.jpg" data-caption="Example of an optional caption." />

Optional callbacks

animationStart and animationEnd run at the start or end of the opening animation. animationStart will run even if there's an error, so it's okay to use if you want to hide your own custom loader.

onClose runs after closing animation finishes.

onChangeImage runs when a gallery image is changed and provides useful data about the current image.

// example of how scrolling can be disabled using callbacks
BigPicture({
	el: e.target,
	animationStart: function () {
		// executed immediately before open animation starts
		document.documentElement.style.overflowY = 'hidden'
		document.body.style.overflowY = 'scroll'
	},
	animationEnd: function () {
		// executed immediately after open animation finishes
		console.log('it has opened')
	},
	onClose: function () {
		// executed immediately after close animation finishes
		document.documentElement.style.overflowY = 'auto'
		document.body.style.overflowY = 'auto'
	},
	onChangeImage: function (props) {
		// executed on gallery image change
		console.log('gallery image changed', props)
	},
})

Hide default loading icon

If you're loading remote images or videos and don't want the default loading icon displayed, set noLoader to true.

BigPicture({
	el: e.target,
	vimeoSrc: '119287310',
	noLoader: true,
})

Change dimensions of embed / youtube / vimeo

By default, embeds are displayed in 16:9 aspect at a maximum of 1920px by 1080px. To change this, supply an array with width and height in pixels. Default is [1920, 1080].

BigPicture({
	el: e.target,
	ytSrc: 'X2lkvrMa27c',
	dimensions: [1226, 900],
})

Error handling

You may override the default error alert for images, audio, and direct video links by passing an onError function.

BigPicture({
	el: e.target,
	onError: function () {
		console.log('there was an error')
	},
})

Troubleshooting

If the media or loading icon fails to display, it's probably a z-index issue. The media container has a default z-index of 9999, and the loading icon has a z-index of 9 relative to the trigger element's parent container.


License: MIT

All images found on Unsplash

Towers of Pfeiffer video by Grant Porter (CC-BY)

Music by Nordgroove via icons8

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].