Class: Spina::Embeds::Youtube
- Defined in:
- app/models/spina/embeds/youtube.rb
Constant Summary collapse
- REGEX =
/(?:youtube(?:-nocookie)?\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|shorts\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/
Instance Method Summary collapse
- #id ⇒ Object
-
#remote_title ⇒ Object
Get title from Youtube API (remote call).
- #to_trix_partial_path ⇒ Object
Methods included from TrixConversion
#to_trix_attachment, #wrap_with_embed_tag
Methods included from Spina::Embeddable
Instance Method Details
#id ⇒ Object
13 14 15 |
# File 'app/models/spina/embeds/youtube.rb', line 13 def id REGEX.match(url).try(:[], 1) end |
#remote_title ⇒ Object
Get title from Youtube API (remote call)
18 19 20 |
# File 'app/models/spina/embeds/youtube.rb', line 18 def remote_title get_youtube_json&.dig("title") end |
#to_trix_partial_path ⇒ Object
22 23 24 |
# File 'app/models/spina/embeds/youtube.rb', line 22 def to_trix_partial_path "spina/embeds/youtubes/thumbnail" end |