Skip to content

Commit 79c62a3

Browse files
authored
Move logic out of thumbnail component template and into the class (#3639)
1 parent 94271e2 commit 79c62a3

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
<% value = presenter.thumbnail.render(@image_options) %>
2-
3-
<% if value %>
4-
<div class="document-thumbnail">
5-
<%= helpers.link_to_document(presenter.document, value, 'aria-hidden': true, tabindex: -1, counter: @counter) %>
6-
</div>
7-
<% end %>
1+
<div class="document-thumbnail">
2+
<%= helpers.link_to_document(presenter.document, thumbnail_value, 'aria-hidden': true, tabindex: -1, counter: @counter) %>
3+
</div>

app/components/blacklight/document/thumbnail_component.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ def initialize(counter:, presenter: nil, image_options: {})
1717

1818
attr_accessor :presenter
1919

20+
def thumbnail_value
21+
@thumbnail_value ||= presenter.thumbnail.render(@image_options)
22+
end
23+
2024
def render?
21-
presenter.thumbnail.exists?
25+
presenter.thumbnail && thumbnail_value
2226
end
2327
end
2428
end

0 commit comments

Comments
 (0)