mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Tweak image max size
This commit is contained in:
parent
9f4cce1070
commit
865efea85c
2 changed files with 4 additions and 8 deletions
|
@ -4,6 +4,8 @@ module Docs
|
|||
class ImagesFilter < Filter
|
||||
include Instrumentable
|
||||
|
||||
DEFAULT_MAX_SIZE = 120_000 # 120 kilobytes
|
||||
|
||||
def self.optimize_image_data(data)
|
||||
@image_optim ||= ImageOptim.new
|
||||
@image_optim.optimize_image_data(data)
|
||||
|
@ -48,7 +50,7 @@ module Docs
|
|||
|
||||
size = image.bytesize
|
||||
|
||||
if size > max_size
|
||||
if size > (context[:max_image_size] || DEFAULT_MAX_SIZE)
|
||||
instrument 'too_big.image', url: url, size: size
|
||||
next
|
||||
end
|
||||
|
@ -64,11 +66,5 @@ module Docs
|
|||
|
||||
doc
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def max_size
|
||||
@max_size ||= context[:max_image_size] || 100.kilobytes
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ module Docs
|
|||
end
|
||||
|
||||
def too_big(event)
|
||||
log "Skipped large image (#{(event.payload[:size] / 1.kilobyte.to_f).round} KB): #{event.payload[:url]}"
|
||||
log "Skipped large image (#{(event.payload[:size] / 1_000.0).round} KB): #{event.payload[:url]}"
|
||||
end
|
||||
|
||||
def error(event)
|
||||
|
|
Loading…
Reference in a new issue