diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb
index 35fe39884..768861d9e 100644
--- a/app/presenters/post_presenter.rb
+++ b/app/presenters/post_presenter.rb
@@ -13,13 +13,23 @@ class PostPresenter < Presenter
html = %{}
html << %{}
- html << %{
}
+ html << %{
}
html << %{}
html << %{}
html.html_safe
end
- def self.margin(post)
+ def self.margin_top(post)
+ if post.is_image? && post.image_height > post.image_width && post.image_height < 2 * post.image_width && post.image_height
+ ratio = Danbooru.config.small_image_width.to_f / post.image_width.to_f
+ offset = ((ratio * post.image_height) - Danbooru.config.small_image_width).to_i / 2
+ return "-#{offset}px"
+ else
+ 0
+ end
+ end
+
+ def self.margin_left(post)
if post.is_image? && post.image_width > post.image_height && post.image_width.to_i > Danbooru.config.small_image_width
ratio = Danbooru.config.small_image_width.to_f / post.image_height.to_f
offset = ((ratio * post.image_width) - Danbooru.config.small_image_width).to_i / 2
diff --git a/app/views/comments/index_by_post.html.erb b/app/views/comments/index_by_post.html.erb
index b8b8bf309..34a9686ab 100644
--- a/app/views/comments/index_by_post.html.erb
+++ b/app/views/comments/index_by_post.html.erb
@@ -9,7 +9,7 @@
<% @posts.each do |post| %>
- <%= link_to(image_tag(post.preview_file_url, :style => "margin-left: #{PostPresenter.margin(post)};"), post_path(post)) %>
+ <%= link_to(image_tag(post.preview_file_url, :style => "margin-left: #{PostPresenter.margin_left(post)}; margin-top: #{PostPresenter.margin_top(post)};"), post_path(post)) %>
<%= render "comments/partials/index/list", :post => post, :comments => post.comments.visible(CurrentUser.user).recent, :show_header => true %>