View Source VideoLinkHelper (video_link_helper v0.3.0)

A helper for extracting IDs from video (Youtube or Vimeo) URLs and rendering embeds for those IDs.

Summary

Functions

Extracts an ID from a link and identifies it as either a Youtube or Vimeo link.

Renders HTML for a video embed.

Functions

create_vimeo_embed(id, height, width)

This function is deprecated. Use VideoLinkHelper.render_embed/2 instead..

create_youtube_embed(id, height, width)

This function is deprecated. Use VideoLinkHelper.render_embed/2 instead..

extract_id(url)

Extracts an ID from a link and identifies it as either a Youtube or Vimeo link.

Examples

iex> VideoLinkHelper.extract_id("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
{:youtube, "dQw4w9WgXcQ"}

render_embed(id, options \\ [])

(since 0.2.0)

Renders HTML for a video embed.

Options

  • :width - Width of the video embed. Default is 560.
  • :height - Height of the video embed. Default is 315.
  • :video_type - The type of video embed to render. Must be either :youtube or :vimeo. If this option is not provided, the default is :youtube.

Returns a string.