Class: Workarea::Storefront::ContentBlocks::VideoViewModel

Inherits:
Workarea::Storefront::ContentBlockViewModel show all
Defined in:
app/view_models/workarea/storefront/content_blocks/video_view_model.rb

Instance Method Summary collapse

Methods inherited from Workarea::Storefront::ContentBlockViewModel

#asset_alt_text, #assets, #find_asset, #partial, #series, wrap

Instance Method Details

#embedObject



16
17
18
19
20
21
22
23
# File 'app/view_models/workarea/storefront/content_blocks/video_view_model.rb', line 16

def embed
  raw_embed
    .gsub(
      /<iframe/,
      "<iframe title='#{t('workarea.storefront.content_blocks.video', url: video_url)}'"
    )
    .gsub(/ frameborder=["'][^"']*["']/, '')
end

#frame_stylesObject



12
13
14
# File 'app/view_models/workarea/storefront/content_blocks/video_view_model.rb', line 12

def frame_styles
  aspect_ratio.present? ? "padding-bottom: #{aspect_ratio}%; height: 0;" : nil
end

#localsObject



5
6
7
8
9
10
# File 'app/view_models/workarea/storefront/content_blocks/video_view_model.rb', line 5

def locals
  super.merge(
    frame_styles: frame_styles,
    embed: embed
  )
end