forked from e621ng/e621ng
Localize background to images so it looks less weird
This commit is contained in:
parent
15923af4ba
commit
4b74a30756
@ -133,10 +133,6 @@ class PostPresenter < Presenter
|
||||
"data-is-favorited" => post.favorited_by?(CurrentUser.user.id)
|
||||
}
|
||||
|
||||
if post.bg_color
|
||||
attributes['style'] = "background-color: ##{post.bg_color}"
|
||||
end
|
||||
|
||||
if post.visible?
|
||||
attributes["data-md5"] = post.md5
|
||||
attributes["data-file-url"] = post.file_url
|
||||
@ -147,6 +143,34 @@ class PostPresenter < Presenter
|
||||
attributes
|
||||
end
|
||||
|
||||
def image_attributes
|
||||
attributes = {
|
||||
:id => "image",
|
||||
class: @post.display_class_for(CurrentUser.user),
|
||||
"data-original-width" => @post.image_width,
|
||||
"data-original-height" => @post.image_height,
|
||||
"data-large-width" => @post.large_image_width,
|
||||
"data-large-height" => @post.large_image_height,
|
||||
"data-tags" => @post.tag_string,
|
||||
:alt => humanized_essential_tag_string,
|
||||
"data-uploader" => @post.uploader_name,
|
||||
"data-rating" => @post.rating,
|
||||
"data-flags" => @post.status_flags,
|
||||
"data-parent-id" => @post.parent_id,
|
||||
"data-has-children" => @post.has_children?,
|
||||
"data-has-active-children" => @post.has_active_children?,
|
||||
"data-score" => @post.score,
|
||||
"data-fav-count" => @post.fav_count,
|
||||
"itemprop" => "contentUrl"
|
||||
}
|
||||
|
||||
if @post.bg_color
|
||||
attributes['style'] = "background-color: ##{@post.bg_color};"
|
||||
end
|
||||
|
||||
attributes
|
||||
end
|
||||
|
||||
def initialize(post)
|
||||
@post = post
|
||||
end
|
||||
|
@ -1,3 +1,3 @@
|
||||
<% if post.visible? %>
|
||||
<%= image_tag(post.file_url_for(CurrentUser.user), :id => "image", class: post.display_class_for(CurrentUser.user), "data-original-width" => post.image_width, "data-original-height" => post.image_height, "data-large-width" => post.large_image_width, "data-large-height" => post.large_image_height, "data-tags" => post.tag_string, :alt => post.presenter.humanized_essential_tag_string, "data-uploader" => post.uploader_name, "data-rating" => post.rating, "data-flags" => post.status_flags, "data-parent-id" => post.parent_id, "data-has-children" => post.has_children?, "data-has-active-children" => post.has_active_children?, "data-score" => post.score, "data-fav-count" => post.fav_count, "itemprop" => "contentUrl") %>
|
||||
<%= image_tag(post.file_url_for(CurrentUser.user), post.presenter.image_attributes) %>
|
||||
<% end %>
|
||||
|
Loading…
Reference in New Issue
Block a user