Skip to content

Commit

Permalink
Also don't relayout for the full view image
Browse files Browse the repository at this point in the history
Same as the previous commit. Didn't seem to want to work but I randomly
figured out the right combination of css, like I usually do
  • Loading branch information
Earlopain committed Oct 3, 2023
1 parent 472b14b commit 42bc6de
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
11 changes: 9 additions & 2 deletions app/helpers/submission_file_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ def display_artist_name?(submission_file)
s1.gsub(/\W+/, "") != s2.gsub(/\W+/, "")
end

def submission_file_tag(submission_file)
dimensions = { width: submission_file.width, height: submission_file.height }
sample = image_tag(url_for(submission_file.sample), loading: "lazy", class: "submission-file", **dimensions)
sample + original_file_tag(submission_file)
end

def original_file_tag(submission_file)
url = url_for(submission_file.original)
dimensions = { width: submission_file.width, height: submission_file.height }
if submission_file.original.content_type.in? ["video/mp4", "video/webm"]
video_tag url, controls: false, class: "submission-file-full hidden"
video_tag(url, controls: false, class: "submission-file-full hidden", **dimensions)
else
image_tag url, loading: "lazy", class: "submission-file-full hidden"
image_tag(url, loading: "lazy", class: "submission-file-full hidden", **dimensions)
end
end
end
2 changes: 2 additions & 0 deletions app/stylesheet/specific/submission_files.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
.submission-file-full {
max-width: 75vw;
max-height: 75vh;
width: auto;
object-fit: contain;
z-index: 2;
position: fixed;
left: 50%;
Expand Down
3 changes: 1 addition & 2 deletions app/views/submission_files/_sample.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
<% if submission_file.sample_generated? %>
<div class="file-container">
<% if submission_file.sample.content_type.in? %w[image/jpeg image/gif] %>
<%= image_tag url_for(submission_file.sample), loading: "lazy", class: "submission-file", width: submission_file.width, height: submission_file.height %>
<%= original_file_tag(submission_file) %>
<%= submission_file_tag(submission_file) %>
<% else %>
Unhandled content_type <%= submission_file.sample.content_type %>
<% end %>
Expand Down

0 comments on commit 42bc6de

Please sign in to comment.