Sha256: e61fb8ea263f30b936a349c21b675192fe137e8856336144b4d9f9c6e3c90969

Contents?: true

Size: 790 Bytes

Versions: 13

Compression:

Stored size: 790 Bytes

Contents

# frozen_string_literal: true

module EffectivePageBannersHelper

  def render_page_banner(page, opts = {}, &block)
    raise('expected a page') unless page.kind_of?(Effective::Page)

    return unless page.banner? || EffectivePages.banners_force_randomize

    # Always return a random banner if config.banners_force_randomize
    page_banner = Effective::PageBanner.deep.random.first if EffectivePages.banners_force_randomize
    page_banner ||= page.page_banner if page.banner? && page.page_banner.present?
    page_banner ||= Effective::PageBanner.deep.random.first if page.banner? && page.banner_random?

    return if page_banner.blank?

    if block_given?
      yield(page_banner); nil
    else
      image_tag(page_banner.file, alt: page_banner.caption, **opts)
    end
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
effective_pages-3.13.4 app/helpers/effective_page_banners_helper.rb
effective_pages-3.13.3 app/helpers/effective_page_banners_helper.rb
effective_pages-3.13.2 app/helpers/effective_page_banners_helper.rb
effective_pages-3.13.1 app/helpers/effective_page_banners_helper.rb
effective_pages-3.13.0 app/helpers/effective_page_banners_helper.rb
effective_pages-3.12.0 app/helpers/effective_page_banners_helper.rb
effective_pages-3.11.0 app/helpers/effective_page_banners_helper.rb
effective_pages-3.10.3 app/helpers/effective_page_banners_helper.rb
effective_pages-3.10.2 app/helpers/effective_page_banners_helper.rb
effective_pages-3.10.1 app/helpers/effective_page_banners_helper.rb
effective_pages-3.10.0 app/helpers/effective_page_banners_helper.rb
effective_pages-3.9.0 app/helpers/effective_page_banners_helper.rb
effective_pages-3.8.4 app/helpers/effective_page_banners_helper.rb