New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

getty-embeddy

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

getty-embeddy

Embed Gettyimages photos (iFrame) using Oembed.

latest
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

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.

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

Keywords

gettyimages

FAQs

Package last updated on 28 Sep 2016

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