discourse/spec/requests/api
David Taylor d0243f741e
UX: Use dominant color as image loading placeholder (#18248)
We previously had a system which would generate a 10x10px preview of images and add their URLs in a data-small-upload attribute. The client would then use that as the background-image of the `<img>` element. This works reasonably well on fast connections, but on slower connections it can take a few seconds for the placeholders to appear. The act of loading the placeholders can also break or delay the loading of the 'real' images.

This commit replaces the placeholder logic with a new approach. Instead of a 10x10px preview, we use imagemagick to calculate the average color of an image and store it in the database. The hex color value then added as a `data-dominant-color` attribute on the `<img>` element, and the client can use this as a `background-color` on the element while the real image is loading. That means no extra HTTP request is required, and so the placeholder color can appear instantly.

Dominant color will be calculated:
1. When a new upload is created
2. During a post rebake, if the dominant color is missing from an upload, it will be calculated and stored
3. Every 15 minutes, 25 old upload records are fetched and their dominant color calculated and stored. (part of the existing PeriodicalUpdates job)

Existing posts will continue to use the old 10x10px placeholder system until they are next rebaked
2022-09-20 10:28:17 +01:00
..
schemas UX: Use dominant color as image loading placeholder (#18248) 2022-09-20 10:28:17 +01:00
shared document user endpoints (#11894) 2021-01-29 11:27:11 -07:00
backups_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
badges_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
categories_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
groups_spec.rb DEV: Use json schema file to describe update group endpoint (#17825) 2022-08-08 17:52:08 +01:00
invites_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
notifications_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
posts_spec.rb DEV: Add before parameter to /posts.json API docs (#18268) 2022-09-16 15:09:15 +01:00
private_messages_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
search_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
site_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
tags_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topics_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
uploads_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_badges_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
users_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00