post tooltips: remove gap beneath thumbnail on post #xxx tooltips.
Set the thumbnail height to auto instead of 154px so that there's not a big empty gap beneath thumbnails that aren't 150px high. This requires setting dimensions on the <img> tag itself so that the image height is known before loading, otherwise the tooltip will be mispositioned after the image loads in. We set the min-width and min-height instead of the <img> width and height properties because our calculated dimensions are sometimes off-by-one compared to the actual dimensions. I'm not sure how libvips calculates the thumbnail dimensions, but this avoids forcing a slightly wrong aspect ratio, which produces ugly resizing artifacts.
This commit is contained in:
@@ -63,6 +63,10 @@ class PostPresenter < Presenter
|
||||
locals[:width] = post.image_width
|
||||
locals[:height] = post.image_height
|
||||
|
||||
downscale_ratio = Danbooru.config.small_image_width.to_f / [post.image_width, post.image_height].max
|
||||
locals[:preview_width] = [(downscale_ratio * post.image_width).floor, post.image_width].min
|
||||
locals[:preview_height] = [(downscale_ratio * post.image_height).floor, post.image_height].min
|
||||
|
||||
if options[:similarity]
|
||||
locals[:similarity] = options[:similarity].round
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user