posts: remove has_dimensions? method.
All posts have non-null width and height now that unsupported filetypes have been purged. https://danbooru.donmai.us/forum_topics/18027
This commit is contained in:
@@ -214,10 +214,6 @@ class Post < ApplicationRecord
|
|||||||
def has_preview?
|
def has_preview?
|
||||||
is_image? || is_video? || is_ugoira?
|
is_image? || is_video? || is_ugoira?
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_dimensions?
|
|
||||||
image_width.present? && image_height.present?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module ImageMethods
|
module ImageMethods
|
||||||
@@ -502,27 +498,25 @@ class Post < ApplicationRecord
|
|||||||
def add_automatic_tags(tags)
|
def add_automatic_tags(tags)
|
||||||
tags -= %w[incredibly_absurdres absurdres highres lowres huge_filesize flash]
|
tags -= %w[incredibly_absurdres absurdres highres lowres huge_filesize flash]
|
||||||
|
|
||||||
if has_dimensions?
|
if image_width >= 10_000 || image_height >= 10_000
|
||||||
if image_width >= 10_000 || image_height >= 10_000
|
tags << "incredibly_absurdres"
|
||||||
tags << "incredibly_absurdres"
|
end
|
||||||
end
|
if image_width >= 3200 || image_height >= 2400
|
||||||
if image_width >= 3200 || image_height >= 2400
|
tags << "absurdres"
|
||||||
tags << "absurdres"
|
end
|
||||||
end
|
if image_width >= 1600 || image_height >= 1200
|
||||||
if image_width >= 1600 || image_height >= 1200
|
tags << "highres"
|
||||||
tags << "highres"
|
end
|
||||||
end
|
if image_width <= 500 && image_height <= 500
|
||||||
if image_width <= 500 && image_height <= 500
|
tags << "lowres"
|
||||||
tags << "lowres"
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if image_width >= 1024 && image_width.to_f / image_height >= 4
|
if image_width >= 1024 && image_width.to_f / image_height >= 4
|
||||||
tags << "wide_image"
|
tags << "wide_image"
|
||||||
tags << "long_image"
|
tags << "long_image"
|
||||||
elsif image_height >= 1024 && image_height.to_f / image_width >= 4
|
elsif image_height >= 1024 && image_height.to_f / image_width >= 4
|
||||||
tags << "tall_image"
|
tags << "tall_image"
|
||||||
tags << "long_image"
|
tags << "long_image"
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if file_size >= 10.megabytes
|
if file_size >= 10.megabytes
|
||||||
|
|||||||
@@ -15,9 +15,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<li id="post-info-size">
|
<li id="post-info-size">
|
||||||
Size: <%= link_to_if policy(post).visible?, "#{number_to_human_size(post.file_size)} .#{post.file_ext}", post.tagged_file_url %>
|
Size: <%= link_to_if policy(post).visible?, "#{number_to_human_size(post.file_size)} .#{post.file_ext}", post.tagged_file_url %>
|
||||||
<% if post.has_dimensions? %>
|
(<%= post.image_width %>x<%= post.image_height %>)
|
||||||
(<%= post.image_width %>x<%= post.image_height %>)
|
|
||||||
<% end %>
|
|
||||||
</li>
|
</li>
|
||||||
<li id="post-info-source">Source: <%= post_source_tag(post.source, post.normalized_source) %></li>
|
<li id="post-info-source">Source: <%= post_source_tag(post.source, post.normalized_source) %></li>
|
||||||
<li id="post-info-rating">Rating: <%= post.pretty_rating %></li>
|
<li id="post-info-rating">Rating: <%= post.pretty_rating %></li>
|
||||||
|
|||||||
@@ -22,9 +22,7 @@
|
|||||||
<span class="info">
|
<span class="info">
|
||||||
<strong>Size</strong>
|
<strong>Size</strong>
|
||||||
<%= link_to "#{upload.post.file_size.to_s(:human_size, precision: 4)} #{upload.post.file_ext}", upload.post.file_url %>
|
<%= link_to "#{upload.post.file_size.to_s(:human_size, precision: 4)} #{upload.post.file_ext}", upload.post.file_url %>
|
||||||
<% if upload.post.has_dimensions? %>
|
(<%= upload.post.image_width %>x<%= upload.post.image_height %>)
|
||||||
(<%= upload.post.image_width %>x<%= upload.post.image_height %>)
|
|
||||||
<% end %>
|
|
||||||
</span>
|
</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
Reference in New Issue
Block a user