0.9.3.5: only generate thumbnails on known extensions, remove trailing '/' from config.files and config.thumbnails
All checks were successful
File-uploader-crystal CI / build (push) Successful in 2m20s
All checks were successful
File-uploader-crystal CI / build (push) Successful in 2m20s
This commit is contained in:
parent
bb9ecee67b
commit
c554b772c8
2 changed files with 13 additions and 0 deletions
|
@ -85,5 +85,12 @@ class Config
|
|||
puts "Config: fileameLength cannot be #{config.fileameLength}"
|
||||
exit(1)
|
||||
end
|
||||
|
||||
if config.files.ends_with?('/')
|
||||
config.files = config.files.chomp('/')
|
||||
end
|
||||
if config.thumbnails.ends_with?('/')
|
||||
config.thumbnails = config.thumbnails.chomp('/')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -115,6 +115,12 @@ module Utils
|
|||
end
|
||||
|
||||
def generate_thumbnail(filename, extension)
|
||||
exts = [".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".webp", ".heic", ".jxl", ".avif", ".crw", ".dng",
|
||||
".mp4", ".mkv", ".webm", ".avi", ".wmv", ".flv", "m4v", ".mov", ".amv", ".3gp", ".mpg", ".mpeg", ".yuv"]
|
||||
# To prevent thumbnail generation on non image extensions
|
||||
return if exts.none? do |ext|
|
||||
extension.downcase.includes?(ext)
|
||||
end
|
||||
# Disable generation if false
|
||||
return if !CONFIG.generateThumbnails || !CONFIG.thumbnails
|
||||
LOGGER.debug "Generating thumbnail for #{filename + extension} in background"
|
||||
|
|
Loading…
Reference in a new issue