posts: always show "resized to X%" notice on mobile.

Always show the "Resized to X% of original" notice when viewing a sample
image on mobile.
This commit is contained in:
evazion
2020-07-31 15:07:36 -05:00
parent 1c6451b4c7
commit 3fe18c57d0
3 changed files with 11 additions and 3 deletions

View File

@@ -430,12 +430,19 @@ div#c-posts {
}
}
body[data-post-current-image-size="large"] .image-view-large-link,
body[data-post-current-image-size="original"] .image-view-original-link,
body[data-post-current-image-size="large"] #post-options .image-view-large-link,
body[data-post-current-image-size="original"] #post-options .image-view-original-link,
body[data-post-current-image-size="original"] #image-resize-notice {
display: none;
}
/* Always show the "Resized to X% of original" notice on mobile when it exists. */
#image-resize-notice {
@media screen and (max-width: 660px) {
display: block !important;
}
}
body.mode-translation .note-container {
cursor: crosshair;
}

View File

@@ -269,6 +269,7 @@ class Post < ApplicationRecord
end
def resize_percentage
return 100 if image_width.to_i == 0
100 * large_image_width.to_f / image_width.to_f
end

View File

@@ -67,7 +67,7 @@
</div>
<% end %>
<% if policy(post).visible? && post.has_large? && !post.is_ugoira? %>
<% if policy(post).visible? && post.has_large? && !post.is_ugoira? && post.resize_percentage.floor < 100 %>
<div class="notice notice-small post-notice post-notice-resized" id="image-resize-notice">
Resized to <%= number_to_percentage post.resize_percentage.floor, precision: 0 %> of original (<%= link_to "view original", post.tagged_file_url, class: "image-view-original-link" %>)
</div>