add image cropping support

This commit is contained in:
Albert Yi
2018-05-16 17:13:36 -07:00
parent df73c682db
commit 64446d49e1
20 changed files with 150 additions and 471 deletions

View File

@@ -34,14 +34,16 @@ class PostPresenter < Presenter
end
html << %{<a href="#{path}/#{post.id}#{tag_param}">}
if options[:show_cropped] && post.has_cropped?
src = post.cropped_file_url
if CurrentUser.id == 1 && options[:show_cropped] && post.has_cropped? && !CurrentUser.user.disable_cropped_thumbnails?
src = post.crop_file_url
imgClass = "cropped"
else
src = post.preview_file_url
imgClass = nil
end
tooltip = "#{post.tag_string} rating:#{post.rating} score:#{post.score}"
html << %{<img itemprop="thumbnailUrl" src="#{src}" title="#{h(tooltip)}" alt="#{h(post.tag_string)}">}
html << %{<img class="#{imgClass}" itemprop="thumbnailUrl" src="#{src}" title="#{h(tooltip)}" alt="#{h(post.tag_string)}">}
html << %{</a>}
if options[:pool]
@@ -71,7 +73,7 @@ class PostPresenter < Presenter
def self.preview_class(post, description = nil, options = {})
klass = "post-preview"
klass << " large-cropped" if post.has_cropped? && options[:show_cropped]
# klass << " large-cropped" if post.has_cropped? && options[:show_cropped]
klass << " pooled" if description
klass << " post-status-pending" if post.is_pending?
klass << " post-status-flagged" if post.is_flagged?

View File

@@ -12,7 +12,7 @@ module PostSetPresenters
end
posts.each do |post|
html << PostPresenter.preview(post, options.merge(:tags => @post_set.tag_string, :raw => @post_set.raw))
html << PostPresenter.preview(post, options.merge(:show_cropped => true, :tags => @post_set.tag_string, :raw => @post_set.raw))
html << "\n"
end