posts: use 180x180 thumbnails in place of 150x150 thumbnails.

For small thumbnails, use 180x180 thumbnails scaled down to 150x150.
This is so we can get rid of 150x150 images and just use 180x180 for
both small and medium size thumbnails.

Also fix RSS feeds, XML sitemaps, and Discord embeds to use 360x360
thumbnails instead of 150x150 thumbnails.
This commit is contained in:
evazion
2021-12-13 02:01:39 -06:00
parent 9eed21ef14
commit e04892fb38
8 changed files with 11 additions and 15 deletions

View File

@@ -56,9 +56,7 @@ class PostPreviewComponent < ApplicationComponent
def variant
case size
when "150"
media_asset.variant("preview")
when "180"
when "150", "180"
media_asset.variant("180x180")
when "225", "225w"
media_asset.variant("360x360")

View File

@@ -17,9 +17,7 @@
<picture>
<% unless save_data %>
<% case size %>
<% when "150" %>
<%# no-op %>
<% when "180" %>
<% when "150", "180" %>
<%= tag.source type: "image/jpeg", srcset: "#{media_asset.variant("180x180").file_url} 1x, #{media_asset.variant("360x360").file_url} 2x" %>
<% else # 225 to 360 %>
<%= tag.source type: "image/webp", srcset: "#{media_asset.variant("360x360").file_url} 1x, #{media_asset.variant("720x720").file_url} 2x" %>

View File

@@ -93,7 +93,7 @@ class CommentsController < ApplicationController
@comments = Comment.paginated_search(params)
if request.format.atom?
@comments = @comments.includes(:creator, :post)
@comments = @comments.includes(:creator, post: [:media_asset])
@comments = @comments.select { |comment| comment.post.visible? }
elsif request.format.html?
@comments = @comments.includes(:creator, :updater, post: [:uploader, :media_asset])

View File

@@ -20,7 +20,7 @@ module SeoHelper
name: page_title,
description: meta_description,
uploadDate: post.created_at.iso8601,
thumbnailUrl: post.preview_file_url,
thumbnailUrl: post.media_asset.variant("360x360").file_url,
contentUrl: post.file_url,
})
end

View File

@@ -26,9 +26,9 @@ class DiscordSlashCommand
if is_censored?
nil
elsif post.file_ext.match?(/jpe?g|png|gif/)
post.file_url
post.media_asset.variant("original").file_url
else
post.preview_file_url
post.media_asset.variant("360x360").file_url
end
end

View File

@@ -11,7 +11,7 @@ atom_feed(root_url: comments_url(host: Danbooru.config.hostname)) do |feed|
feed.entry(comment, published: comment.created_at, updated: comment.updated_at) do |entry|
entry.title("@#{comment.creator.name} on post ##{comment.post_id} (#{comment.post.presenter.humanized_essential_tag_string})")
entry.content(<<-EOS.strip_heredoc, type: "html")
<img src="#{comment.post.preview_file_url}"/>
<img src="#{comment.post.media_asset.variant("360x360").file_url}"/>
#{format_text(comment.body)}
EOS

View File

@@ -23,7 +23,7 @@
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<%= link_to post_url(post) do %>
<%= image_tag post.preview_file_url %>
<%= image_tag post.media_asset.variant("360x360").file_url %>
<% end %>
<p><%= post.tag_string %></p>
</div>

View File

@@ -12,12 +12,12 @@
<% if post.visible? %>
<% if post.is_image? %>
<image:image>
<image:loc><%= post.file_url %></image:loc>
<image:loc><%= post.media_asset.variant("original").file_url %></image:loc>
</image:image>
<% elsif post.is_video? %>
<video:video>
<video:thumbnail_loc><%= post.preview_file_url %></video:thumbnail_loc>
<video:content_loc><%= post.file_url %></video:content_loc>
<video:thumbnail_loc><%= post.media_asset.variant("360x360").file_url %></video:thumbnail_loc>
<video:content_loc><%= post.media_asset.variant("original").file_url %></video:content_loc>
<video:publication_date><%= post.created_at.iso8601 %></video:publication_date>
<video:title><%= "Post ##{post.id}" %></video:title>
<video:description><%= post.tag_string %></video:description>