npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

strano-bigpicture

v1.6.1

Published

Lightweight image and video viewer, supports youtube/vimeo

Downloads

6

Readme

logo BigPicture.js

Example page screenshot

Credits

This is a forked and modified versione of the original BigPicture library that you can find at: https://github.com/henrygd/bigpicture This modified version implements the ability to retrieve video type from the configuration object. You can even include a JSON encoded version of the video configuration object/array in the vidSrc DOM attribute.

Lightweight (3.5 KB gzip) and framework independent JavaScript image / video viewer.

Supports Youtube, Vimeo, and direct video links.

Doesn't sit on the DOM when inactive.

Check out the example page here

Instructions

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

npm install strano-bigpicture
var BigPicture = require('strano-bigpicture')

Or with a script tag:

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

No additional CSS file is neccesary.

When you want to open something, pass an object to BigPicture containing the element from which you want the animation to start and an optional second parameter depending on what you want to do. Examples below use this 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).

Remote video file

Multiple sources supported as of 1.4.0

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

...you can even define the media type for every video source

BigPicture({
  el: this,
  vidSrc: {
    url: 'http://yourvideo.mp4',
    type: 'video/mp4'
  }
  // or with multiple sources
  // vidSrc: [
  //   {
  //     url: 'http://yourvideo.mp4',
  //     type: 'video/mp4'
  //   },
  //   {
  //     url: 'http://yourvideo.webm',
  //     type: 'video/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: this,
  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: this,
  vimeoSrc: '119287310'
})
Audio
BigPicture({
  el: this,
  audio: 'http://youraudio.mp3'
})
Remote individual image
BigPicture({
  el: this,
  imgSrc: 'http://yourimage.jpg'
})
Local images & background images

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

BigPicture({
  el: this
})
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.

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

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: this,
  gallery: unsplashImages
})

Captions

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

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

Optional callbacks

To execute specified functions at the start or end of the opening animation, pass them in as animationStart or animationEnd. animationStart will run even if there's an error, so it's okay to use if you want to hide your own custom loader.

BigPicture({
  el: this,
  // executed immediately before open animation starts
  animationStart: function() {
    console.log('it is opening')
  },
  // executed immediately after open animation finishes
  animationEnd: function() {
    console.log('it has opened')
  }
})

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: this,
  vimeoSrc: '119287310',
  noLoader: true
})

Error handling

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

BigPicture({
  el: this,
  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