post preview component: remove workaround for blank width/height.

Remove workaround for old posts that had a null width or height. These
posts were fixed a while ago.
This commit is contained in:
evazion
2021-09-25 06:29:51 -05:00
parent 6f02918676
commit 51bc953383

View File

@@ -40,17 +40,12 @@ class PostPreviewComponent < ApplicationComponent
end
def preview_dimensions
# XXX work around ancient bad posts with null or zero dimensions.
if post.image_width.to_i > 0 && post.image_height.to_i > 0
downscale_ratio = Danbooru.config.small_image_width.to_f / [post.image_width, post.image_height].max
downscale_ratio = Danbooru.config.small_image_width.to_f / [post.image_width, post.image_height].max
{
width: [(downscale_ratio * post.image_width).floor, post.image_width].min,
height: [(downscale_ratio * post.image_height).floor, post.image_height].min,
}
else
{ width: 0, height: 0 }
end
{
width: [(downscale_ratio * post.image_width).floor, post.image_width].min,
height: [(downscale_ratio * post.image_height).floor, post.image_height].min,
}
end
def tooltip