Welcome to mirror list, hosted at ThFree Co, Russian Federation.

video_link_filter.rb « filter « banzai « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c7a01f5583c84b9445b687a1eecff7c6cf6c4f08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

# Generated HTML is transformed back to GFM by app/assets/javascripts/behaviors/markdown/nodes/video.js
module Banzai
  module Filter
    class VideoLinkFilter < PlayableLinkFilter
      private

      def media_type
        'video'
      end

      def safe_media_ext
        Gitlab::FileTypeDetection::SAFE_VIDEO_EXT
      end

      def extra_element_attrs(element)
        attrs = { preload: 'metadata' }

        attrs[:height] = element[:height] if element[:height]
        attrs[:width] = element[:width] if element[:width]
        attrs[:width] = '400' unless attrs[:width] || attrs[:height]

        attrs
      end
    end
  end
end