posts: use low quality thumbnails when Save-Data header is set.
When the Save-Data HTTP header is present, disable high quality (2x pixel density) thumbnails. This is normally set when "Data Saver mode" is enabled on Android, or "Lite mode" is enabled in Chrome. This setting can also be set using the `save_data` URL param or HTTP cookie. This is mainly for testing. The <body> tag has a `current-user-save-data` data attribute that indicates whether save data mode is on. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Save-Data https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/save-data/#the_save-data_request_header https://source.android.com/devices/tech/connect/data-saver
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# A global variable containing the current user, the current IP address, the
|
||||
# current user's country code, and whether safe mode is enabled.
|
||||
# current user's country code, whether safe mode is enabled, and whether
|
||||
# save-data mode is enabled.
|
||||
#
|
||||
# The current user is set during a request by {ApplicationController#set_current_user},
|
||||
# which calls {SessionLoader#load}. The current user will not be set outside of
|
||||
@@ -11,7 +12,7 @@
|
||||
# @see ApplicationController#set_current_user
|
||||
# @see SessionLoader#load
|
||||
class CurrentUser < ActiveSupport::CurrentAttributes
|
||||
attribute :user, :ip_addr, :country, :safe_mode
|
||||
attribute :user, :ip_addr, :country, :safe_mode, :save_data
|
||||
|
||||
alias_method :safe_mode?, :safe_mode
|
||||
delegate :id, to: :user, allow_nil: true
|
||||
|
||||
Reference in New Issue
Block a user