Sha256: d8d08c4f68a28467f3ff1f4ed9708389989bd2af5ef6bd97114781a1eef0432a

Contents?: true

Size: 887 Bytes

Versions: 25

Compression:

Stored size: 887 Bytes

Contents

module Alchemy
  module Ingredients
    class VideoView < BaseView
      delegate :attachment, to: :ingredient

      def call
        content_tag(:video, html_options) do
          tag(:source, src: src, type: attachment.file_mime_type)
        end
      end

      def render?
        !attachment.nil?
      end

      private

      def src
        alchemy.show_attachment_path(
          attachment,
          format: attachment.suffix
        )
      end

      def html_options
        {
          controls: ingredient.controls,
          autoplay: ingredient.autoplay,
          loop: ingredient.loop,
          muted: ingredient.muted,
          playsinline: ingredient.playsinline,
          preload: ingredient.preload.presence,
          width: ingredient.width.presence,
          height: ingredient.height.presence
        }.merge(@html_options)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
alchemy_cms-7.0.1 app/components/alchemy/ingredients/video_view.rb
alchemy_cms-7.0.0 app/components/alchemy/ingredients/video_view.rb
alchemy_cms-7.0.0.pre.rc1 app/components/alchemy/ingredients/video_view.rb
alchemy_cms-7.0.0.pre.c app/components/alchemy/ingredients/video_view.rb
alchemy_cms-7.0.0.pre.b app/components/alchemy/ingredients/video_view.rb