Sha256: de7a5b5ad32a467feadb7a3df21b547a9e5d96d3cf832ec15825dc9ec20d0601

Contents?: true

Size: 961 Bytes

Versions: 7

Compression:

Stored size: 961 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # This cell renders the media link card for an instance of a MediaLink
  class PhotoCell < Decidim::ViewModel
    include Decidim::ApplicationHelper
    include Decidim::LayoutHelper
    include Decidim::SanitizeHelper

    def show
      render
    end

    private

    def index
      @options[:index]
    end

    def image_alt
      strip_tags(description) || strip_tags(translated_attribute(model.title)) || t("alt", scope: "decidim.application.photo")
    end

    def image_thumb
      image_tag model.thumbnail_url, alt: image_alt
    end

    def image_big
      image_tag model.big_url, alt: image_alt
    end

    def title
      decidim_html_escape(translated_attribute(model.title))
    end

    def short_description
      decidim_sanitize_editor html_truncate(description, length: 100, separator: "...")
    end

    def description
      translated_attribute(model.description)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.28.4 app/cells/decidim/photo_cell.rb
decidim-core-0.28.3 app/cells/decidim/photo_cell.rb
decidim-core-0.28.2 app/cells/decidim/photo_cell.rb
decidim-core-0.28.1 app/cells/decidim/photo_cell.rb
decidim-core-0.28.0 app/cells/decidim/photo_cell.rb
decidim-core-0.28.0.rc5 app/cells/decidim/photo_cell.rb
decidim-core-0.28.0.rc4 app/cells/decidim/photo_cell.rb