Skip to content

Options

Shobhit Sharma edited this page Oct 30, 2020 · 9 revisions

Initialize Options

new Embed([options]) Defaults

// With default SDK
new Embedo({
  facebook: {
    version: "v3.2",
    appId: "269918776508696",
    access_token: "f4k3t0k3n",
    xfbml: true
  }
});

// Enabled twitter SDK
new Embedo({ twitter: true });

// Enabled instagram SDK
new Embedo({ 
  instagram: { 
    access_token: "f4k3t0k3n"
  }
});

// Enabled pinterest SDKa
new Embedo({ pinterest: true });

// Enabled reddit SDK
new Embedo({ reddit: true });

// Enabled flickr SDK
new Embedo({ flickr: true });

// Enabled twitter SDK
new Embedo({
  googlemaps: {
    key: "ENTER_TEST_KEY_HERE"
  }
});

Overriding SDK

// Custom SDK Format
new Embedo({
  [source: string (facebook/twitter/...)]: {
    sdk: string
  }
})

// Example for override facebook SDK
new Embedo({
  facebook: {
   sdk: "https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.2"
  }
})

Load Options

The options are native and external based as described below:

Native Options

Parameter Type Default Description
width number null Custom width of container (gets ignored if not supported via SDK)
height number null Custom height of container (gets ignored if not supported via SDK)
centerize boolean true Centering rendered element to center horizontally or vertically
strict boolean false Enable or disable auto-resizing functionality

External Options

  • Facebook - Supports maxwidth, omitscript (API Reference)
  • Twitter - See Parameters section here
  • Instagram - Supports hidecaption, maxwidth, omitscript (API Reference)
  • YouTube - See Supported Parameters section here
  • Pinterest - See API Reference
  • Google Maps - Supports zoom as integer and mapTypeId as enum as roadmap/satellite/hybrid/terrain (API Reference)
  • Others/iFrame: tagName (identifier for HTML Tag, defaults to embed)

Examples

// Defaults when no option argument is passed
embedo.load(
  document.getElementById("embedo-youtube-embed"),
  "my://awesome/url",
  {
    width: null,
    height: null,
    centerize: true,
    strict: false
  }
);

// For article mode, where size or centering wont matter, use:
embedo.load(
  document.getElementById("embedo-youtube-embed"),
  ["my://awesome/url1", "my://awesome/url2"],
  {
    centerize: false,
    strict: true
  }
);

// Example to embed youtube video by passing native options
embedo.load(
  document.getElementById("embedo-youtube-embed"),
  "https://www.youtube.com/embed/vn2qXpcon-s",
  {
    width: 640,
    height: 480
  }
);

// Embeds instagram post by passing external options
embedo.load(
  document.getElementById("embedo-multiple"),
  [
    "https://www.instagram.com/p/BX3fMnRjHpZ",
    "https://www.instagram.com/p/BX3ejdJHmkD",
    "https://www.instagram.com/p/BX3VEDqFvmg"
  ],
  {
    hidecaption: false
  }
);

// Embeds pinterest profile by passing external and native options
embedo.load(
  document.getElementById("embedo-pinterest-profile"),
  "https://www.pinterest.com/pinterest/",
  {
    "data-pin-do": "embedUser",
    "data-pin-board-width": 750,
    "data-pin-scale-height": 500,
    "data-pin-scale-width": 80,
    strict: true
  }
);
Clone this wiki locally