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

getty-embeddy

v1.1.1

Published

Embed Gettyimages photos (iFrame) using Oembed.

Downloads

23

Readme

getty-embeddy

npm version Build Status codecov.io

Embed Gettyimages photos (iFrame) into your website using Gettyimages's native oEmbed endpoint.

the concept was as lightweight and direct as possible for smaller footprint so if you want a power horse with > 500 LOC check something like embedza, url-embed or jquery-oembed-all. However, make sure they support Gettyimages!

Feedback and PRs are welcomed.

you made a library for THAT! no chance, I will create my Iframe link on my own!

well, you can't -.-

unlike other social services out there, GettyImages kinda forces you to use oEmbed (or their API) to get the working iframe link.

However, if you managed to generate the url on the fly, please tell me!

Install

$ npm install --save getty-embeddy

Usage

var GettyEmbeddy = require('getty-embeddy');
// all options are optional with the default values shown here:
var gettyEmbeddy = new GettyEmbeddy({
  // undefined to search in whole document or an element to use as parent for better performance (recommended!)
  parentEl: undefined,    
  // all elements with this class will be processed          
  selectorClass: 'js-getty-embeddy-el',
  // which data attr will hold the GettyImages image id
  dataAttr: 'getty-embeddy-id',
  //provide the src (link) attribute for the loading image or false to disable
  //any valid src is accepted (url,base64,svg...)
  loaderImgSrc: 'data:image/gif;base64,R0lGOD....[a small gif loader encoded in base64]',
  // a function to run if embedding fails (image was removed or invalid id etc...)
  // el is the affected element and reason is a string, one of 'no_image_id','invalid_response','connection_error'
  onLoadFail: function (el, reason) {
    if (el && reason && this.options.defaultOnFailHtml && this.options.defaultOnFailHtml.replace) {
      el.innerHTML = this.options.defaultOnFailHtml.replace('__REASON__', reason);
    }
    console.warn('GettyEmbeddy - onLoadFail was called reason:', reason, ' element:', el);
  },
  // if you don't want to provide different onFail function, you can simply change the html here
  // '__REASON__' will be replaced with the fail reason if found
  defaultOnFailHtml: '<span>embedding failed reason:__REASON__</span>',
  // the css to use for the loader element
  loaderCss: 'margin:auto;display:block;top:50%;position:relative;',
  // the time (in milliseconds) to delay the embedAll process for better performance, set to 0 to disable
  embedDelayDuration: 100,
});

gettyEmbeddy.embedAll(); // will scan parentEl for possible embeds and load them (with the 'embedDelayDuration' delay between each embed)
gettyEmbeddy.embed(el); //will check el's data attributes for dataAttr to get image id
gettyEmbeddy.embed(el, '604533586'); // you can provide the id directly if the element doesn't have one or if you need to override it
// gettyEmbeddy.getHtml(gettyId); //TODO