switch post previews to use flexbox, add better styling for cropped thumbnails
This commit is contained in:
@@ -21,15 +21,13 @@ class PostPresenter < Presenter
|
||||
end
|
||||
|
||||
path = options[:path_prefix] || "/posts"
|
||||
if Danbooru.config.enable_image_cropping && CurrentUser.id == 1 && options[:show_cropped] && post.has_cropped? && !CurrentUser.user.disable_cropped_thumbnails?
|
||||
src = post.crop_file_url
|
||||
imgClass = "cropped"
|
||||
if Danbooru.config.enable_image_cropping && options[:show_cropped] && post.has_cropped? && !CurrentUser.user.disable_cropped_thumbnails?
|
||||
cropped_src = post.crop_file_url
|
||||
else
|
||||
src = post.preview_file_url
|
||||
imgClass = nil
|
||||
cropped_src = post.preview_file_url
|
||||
end
|
||||
|
||||
html = %{<article itemscope itemtype="http://schema.org/ImageObject" id="post_#{post.id}" class="#{imgClass} #{preview_class(post, options[:pool], options)}" #{data_attributes(post)}>}
|
||||
html = %{<article itemscope itemtype="http://schema.org/ImageObject" id="post_#{post.id}" class="#{preview_class(post, options[:pool], options)}" #{data_attributes(post)}>}
|
||||
if options[:tags].present? && !CurrentUser.is_anonymous?
|
||||
tag_param = "?tags=#{CGI::escape(options[:tags])}"
|
||||
elsif options[:pool_id] || options[:pool]
|
||||
@@ -42,7 +40,11 @@ class PostPresenter < Presenter
|
||||
html << %{<a href="#{path}/#{post.id}#{tag_param}">}
|
||||
|
||||
tooltip = "#{post.tag_string} rating:#{post.rating} score:#{post.score}"
|
||||
html << %{<img class="#{imgClass}" itemprop="thumbnailUrl" src="#{src}" title="#{h(tooltip)}" alt="#{h(post.tag_string)}">}
|
||||
html << %{<picture>}
|
||||
html << %{<source media="(max-width: 660px)" srcset="#{cropped_src}">}
|
||||
html << %{<source media="(min-width: 660px)" srcset="#{post.preview_file_url}">}
|
||||
html << %{<img itemprop="thumbnailUrl" src="#{post.preview_file_url}" title="#{h(tooltip)}" alt="#{h(post.tag_string)}">}
|
||||
html << %{</picture>}
|
||||
html << %{</a>}
|
||||
|
||||
if options[:pool]
|
||||
|
||||
@@ -12,7 +12,7 @@ module PostSetPresenters
|
||||
end
|
||||
|
||||
posts.each do |post|
|
||||
html << PostPresenter.preview(post, options.merge(:show_cropped => true, :tags => @post_set.tag_string, :raw => @post_set.raw))
|
||||
html << PostPresenter.preview(post, options.merge(:tags => @post_set.tag_string, :raw => @post_set.raw))
|
||||
html << "\n"
|
||||
end
|
||||
|
||||
|
||||
@@ -11,6 +11,10 @@ module PostSetPresenters
|
||||
@tag_set_presenter ||= TagSetPresenter.new(related_tags)
|
||||
end
|
||||
|
||||
def post_previews_html(template, options = {})
|
||||
super(template, options.merge(show_cropped: true))
|
||||
end
|
||||
|
||||
def related_tags
|
||||
if post_set.is_pattern_search?
|
||||
pattern_tags
|
||||
|
||||
Reference in New Issue
Block a user