Skip to content

Commit

Permalink
Deprivatize useful picture view methods (#1936)
Browse files Browse the repository at this point in the history
Useful eg for custom picture tag creation
  • Loading branch information
mickenorlen authored Oct 14, 2020
1 parent 27a66a3 commit 2b32de1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/models/alchemy/essence_picture_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,19 @@ def render
end
end

private

def caption
return unless show_caption?

@_caption ||= content_tag(:figcaption, essence.caption)
end

def src
essence.picture_url(options.except(*DEFAULT_OPTIONS.keys))
end

def img_tag
@_img_tag ||= image_tag(
essence.picture_url(options.except(*DEFAULT_OPTIONS.keys)), {
src, {
alt: alt_text,
title: essence.title.presence,
class: caption ? nil : essence.css_class.presence,
Expand Down

0 comments on commit 2b32de1

Please sign in to comment.