Class: PublifyApp::Textfilter::Youtube
- Inherits:
-
TextFilterPlugin::MacroPost
- Object
- TextFilterPlugin::MacroPost
- PublifyApp::Textfilter::Youtube
- Defined in:
- lib/publify_app/textfilter_youtube.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ width: 560, height: 315 }.freeze
Class Method Summary collapse
Class Method Details
.help_text ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/publify_app/textfilter_youtube.rb', line 12 def self.help_text %{ You can use `<publify:youtube v="eXamPL" />` to embed Youtube videos. Options: * **v**. Required, the video_id. * **width**. 560 by default. * **height**. Height. 315 by default. * **start**. Sets the start time } end |
.macrofilter(attrib) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/publify_app/textfilter_youtube.rb', line 25 def self.macrofilter(attrib) video_id = attrib["v"] return '' unless video_id # Video ID is required width = attrib.fetch("width", DEFAULT_OPTIONS[:width]) height = attrib.fetch("height", DEFAULT_OPTIONS[:height]) start = attrib["start"] src = "https://www.youtube.com/embed/#{video_id}" src += "?start=#{start}" if start %(<iframe width="#{width}" height="#{height}" src="#{src}" frameborder="0") \ ' allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope;' \ ' picture-in-picture; web-share"' \ ' referrerpolicy="strict-origin-when-cross-origin" allowfullscreen>' \ '</iframe>' end |