mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: reduce avatar sizes to 6 from 20 (#21319)
* FEATURE: reduce avatar sizes to 6 from 20 This PR introduces 3 changes: 1. SiteSetting.avatar_sizes, now does what is says on the tin. previously it would introduce a large number of extra sizes, to allow for various DPIs. Instead we now trust the admin with the size list. 2. When `avatar_sizes` changes, we ensure consistency and remove resized avatars that are not longer allowed per site setting. This happens on the 12 hourly job and limited out of the box to 20k cleanups per cycle, given this may reach out to AWS 20k times to remove things. 3.Our default avatar sizes are now "24|48|72|96|144|288" these sizes were very specifically picked to limit amount of bluriness introduced by webkit. Our avatars are already blurry due to 1px border, so this corrects old blur. This change heavily reduces storage required by forums which simplifies site moves and more. Co-authored-by: David Taylor <david@taylorhq.com>
This commit is contained in:
@@ -162,12 +162,12 @@ RSpec.describe UserAnonymizer do
|
||||
[/quote]
|
||||
RAW
|
||||
|
||||
old_avatar_url = user.avatar_template.gsub("{size}", "40")
|
||||
old_avatar_url = user.avatar_template.gsub("{size}", "48")
|
||||
expect(post.cooked).to include(old_avatar_url)
|
||||
|
||||
make_anonymous
|
||||
post.reload
|
||||
new_avatar_url = user.reload.avatar_template.gsub("{size}", "40")
|
||||
new_avatar_url = user.reload.avatar_template.gsub("{size}", "48")
|
||||
|
||||
expect(post.cooked).to_not include(old_avatar_url)
|
||||
expect(post.cooked).to include(new_avatar_url)
|
||||
|
||||
@@ -425,7 +425,7 @@ RSpec.describe UsernameChanger do
|
||||
let(:quoted_post) do
|
||||
create_post(user: user, topic: topic, post_number: 1, raw: "quoted post")
|
||||
end
|
||||
let(:avatar_url) { user.avatar_template_url.gsub("{size}", "40") }
|
||||
let(:avatar_url) { user.avatar_template_url.gsub("{size}", "48") }
|
||||
|
||||
it "replaces the username in quote tags and updates avatar" do
|
||||
post = create_post_and_change_username(raw: <<~RAW)
|
||||
@@ -469,7 +469,7 @@ RSpec.describe UsernameChanger do
|
||||
<aside class="quote no-group" data-username="bar" data-post="1" data-topic="#{quoted_post.topic.id}">
|
||||
<div class="title">
|
||||
<div class="quote-controls"></div>
|
||||
<img loading="lazy" alt='' width="20" height="20" src="#{avatar_url}" class="avatar"> bar:</div>
|
||||
<img loading="lazy" alt='' width="24" height="24" src="#{avatar_url}" class="avatar"> bar:</div>
|
||||
<blockquote>
|
||||
<p>quoted post</p>
|
||||
</blockquote>
|
||||
@@ -477,7 +477,7 @@ RSpec.describe UsernameChanger do
|
||||
<aside class="quote no-group" data-username="bar">
|
||||
<div class="title">
|
||||
<div class="quote-controls"></div>
|
||||
<img loading="lazy" alt="" width="20" height="20" src="#{avatar_url}" class="avatar"> bar:</div>
|
||||
<img loading="lazy" alt="" width="24" height="24" src="#{avatar_url}" class="avatar"> bar:</div>
|
||||
<blockquote>
|
||||
<p>quoted post</p>
|
||||
</blockquote>
|
||||
@@ -485,7 +485,7 @@ RSpec.describe UsernameChanger do
|
||||
<aside class="quote no-group" data-username="bar" data-post="1" data-topic="#{quoted_post.topic.id}">
|
||||
<div class="title">
|
||||
<div class="quote-controls"></div>
|
||||
<img loading="lazy" alt="" width="20" height="20" src="#{avatar_url}" class="avatar"> bar:</div>
|
||||
<img loading="lazy" alt="" width="24" height="24" src="#{avatar_url}" class="avatar"> bar:</div>
|
||||
<blockquote>
|
||||
<p>quoted post</p>
|
||||
</blockquote>
|
||||
@@ -516,7 +516,7 @@ RSpec.describe UsernameChanger do
|
||||
<aside class="quote no-group" data-username="bar" data-post="1" data-topic="#{quoted_post.topic.id}">
|
||||
<div class="title">
|
||||
<div class="quote-controls"></div>
|
||||
<img loading="lazy" alt='' width="20" height="20" src="#{avatar_url}" class="avatar"> bar:</div>
|
||||
<img loading="lazy" alt='' width="24" height="24" src="#{avatar_url}" class="avatar"> bar:</div>
|
||||
<blockquote>
|
||||
<p>quoted</p>
|
||||
</blockquote>
|
||||
@@ -550,7 +550,7 @@ RSpec.describe UsernameChanger do
|
||||
end
|
||||
|
||||
def user_avatar_url(u)
|
||||
u.avatar_template_url.gsub("{size}", "40")
|
||||
u.avatar_template_url.gsub("{size}", "48")
|
||||
end
|
||||
|
||||
it "updates avatar for linked topics and posts" do
|
||||
@@ -562,7 +562,7 @@ RSpec.describe UsernameChanger do
|
||||
<aside class="quote" data-post="#{quoted_post.post_number}" data-topic="#{quoted_post.topic.id}">
|
||||
<div class="title">
|
||||
<div class="quote-controls"></div>
|
||||
<img loading="lazy" alt="" width="20" height="20" src="#{avatar_url}" class="avatar">
|
||||
<img loading="lazy" alt="" width="24" height="24" src="#{avatar_url}" class="avatar">
|
||||
<a href="#{protocol_relative_url(quoted_post.full_url)}">#{quoted_post.topic.title}</a>
|
||||
</div>
|
||||
<blockquote>
|
||||
@@ -573,7 +573,7 @@ RSpec.describe UsernameChanger do
|
||||
<aside class="quote" data-post="#{quoted_post.post_number}" data-topic="#{quoted_post.topic.id}">
|
||||
<div class="title">
|
||||
<div class="quote-controls"></div>
|
||||
<img loading="lazy" alt="" width="20" height="20" src="#{avatar_url}" class="avatar">
|
||||
<img loading="lazy" alt="" width="24" height="24" src="#{avatar_url}" class="avatar">
|
||||
<a href="#{protocol_relative_url(quoted_post.topic.url)}">#{quoted_post.topic.title}</a>
|
||||
</div>
|
||||
<blockquote>
|
||||
@@ -592,7 +592,7 @@ RSpec.describe UsernameChanger do
|
||||
<aside class="quote" data-post="#{quoted_post.post_number}" data-topic="#{quoted_post.topic.id}">
|
||||
<div class="title">
|
||||
<div class="quote-controls"></div>
|
||||
<img loading="lazy" alt="" width="20" height="20" src="#{avatar_url}" class="avatar">
|
||||
<img loading="lazy" alt="" width="24" height="24" src="#{avatar_url}" class="avatar">
|
||||
<a href="#{protocol_relative_url(quoted_post.full_url)}">#{quoted_post.topic.title}</a>
|
||||
</div>
|
||||
<blockquote>
|
||||
@@ -603,7 +603,7 @@ RSpec.describe UsernameChanger do
|
||||
<aside class="quote" data-post="#{another_quoted_post.post_number}" data-topic="#{another_quoted_post.topic.id}">
|
||||
<div class="title">
|
||||
<div class="quote-controls"></div>
|
||||
<img loading="lazy" alt="" width="20" height="20" src="#{user_avatar_url(evil_trout)}" class="avatar">
|
||||
<img loading="lazy" alt="" width="24" height="24" src="#{user_avatar_url(evil_trout)}" class="avatar">
|
||||
<a href="#{protocol_relative_url(another_quoted_post.full_url)}">#{another_quoted_post.topic.title}</a>
|
||||
</div>
|
||||
<blockquote>
|
||||
|
||||
Reference in New Issue
Block a user