Class: Banzai::Filter::PlayableLinkFilter

Inherits:
HTML::Pipeline::Filter
  • Object
show all
Defined in:
lib/banzai/filter/playable_link_filter.rb

Overview

Find every image that isn't already wrapped in an `a` tag, and that has a `src` attribute ending with an audio or video extension, add a new audio or video node and a “Download” link in the case the media cannot be played.

Direct Known Subclasses

AudioLinkFilter, VideoLinkFilter

Instance Method Summary collapse

Instance Method Details

#callObject


9
10
11
12
13
14
15
# File 'lib/banzai/filter/playable_link_filter.rb', line 9

def call
  doc.xpath('descendant-or-self::img[not(ancestor::a)]').each do |el|
    el.replace(media_node(doc, el)) if has_media_extension?(el)
  end

  doc
end