Sensible defaults — users only need to configure originals and output
(or even nothing at all). All other values fall back to these.
"assets/images/originals"
DEFAULT_OUTPUT =
"assets/images/optimized"
DEFAULT_INPUT_FORMATS =
%w[jpgjpegpngwebpavifgiftifftifsvg].freeze
DEFAULT_FORMATS =
Output format priority: avif > webp > png > jpg (fallback).
The browser picks the first format it supports, so avif is
served to modern browsers, webp as a fallback for avif, png for
transparency, and jpg as the universal fallback.
# File 'lib/jekyll-imgflow/config.rb', line 30definitialize(site)@site=sitecfg=merged_configassign_core_config(cfg)assign_provider_config(cfg)@optimize_qualities=cfg["optimize_qualities"]||default_optimize_qualitiesvalidate_backend_priority!end
Instance Attribute Details
#backend_priority ⇒ Object(readonly)
Returns the value of attribute backend_priority.
25
26
27
# File 'lib/jekyll-imgflow/config.rb', line 25defbackend_priority@backend_priorityend
#fallback_format ⇒ Object(readonly)
Returns the value of attribute fallback_format.
25
26
27
# File 'lib/jekyll-imgflow/config.rb', line 25deffallback_format@fallback_formatend
#flyimg_url ⇒ Object(readonly)
Returns the value of attribute flyimg_url.
25
26
27
# File 'lib/jekyll-imgflow/config.rb', line 25defflyimg_url@flyimg_urlend
#formats ⇒ Object(readonly)
Returns the value of attribute formats.
25
26
27
# File 'lib/jekyll-imgflow/config.rb', line 25defformats@formatsend
#image_modal ⇒ Object(readonly)
Returns the value of attribute image_modal.
25
26
27
# File 'lib/jekyll-imgflow/config.rb', line 25defimage_modal@image_modalend
#imgproxy_url ⇒ Object(readonly)
Returns the value of attribute imgproxy_url.
25
26
27
# File 'lib/jekyll-imgflow/config.rb', line 25defimgproxy_url@imgproxy_urlend
#input_formats ⇒ Object(readonly)
Returns the value of attribute input_formats.
25
26
27
# File 'lib/jekyll-imgflow/config.rb', line 25definput_formats@input_formatsend
#optimize_qualities ⇒ Object(readonly)
Returns the value of attribute optimize_qualities.
25
26
27
# File 'lib/jekyll-imgflow/config.rb', line 25defoptimize_qualities@optimize_qualitiesend
#originals ⇒ Object(readonly)
Returns the value of attribute originals.
25
26
27
# File 'lib/jekyll-imgflow/config.rb', line 25deforiginals@originalsend
#output ⇒ Object(readonly)
Returns the value of attribute output.
25
26
27
# File 'lib/jekyll-imgflow/config.rb', line 25defoutput@outputend
#quality ⇒ Object(readonly)
Returns the value of attribute quality.
25
26
27
# File 'lib/jekyll-imgflow/config.rb', line 25defquality@qualityend
#site ⇒ Object(readonly)
Returns the value of attribute site.
25
26
27
# File 'lib/jekyll-imgflow/config.rb', line 25defsite@siteend
#sizes ⇒ Object(readonly)
Returns the value of attribute sizes.
25
26
27
# File 'lib/jekyll-imgflow/config.rb', line 25defsizes@sizesend
#weserv_url ⇒ Object(readonly)
Returns the value of attribute weserv_url.
25
26
27
# File 'lib/jekyll-imgflow/config.rb', line 25defweserv_url@weserv_urlend
# File 'lib/jekyll-imgflow/config.rb', line 51defassign_provider_config(cfg)@imgproxy_url=cfg["imgproxy_url"]@weserv_url=cfg["weserv_url"]@flyimg_url=cfg["flyimg_url"]end
#cache_dir ⇒ Object
67
68
69
# File 'lib/jekyll-imgflow/config.rb', line 67defcache_dirmerged_config["cache_dir"]||".cache/imgflow"end
Determine if params represent a default or specialized version
Parameters:
params(Hash)
—
Operation parameters
Returns:
(Symbol)
—
:default or :specialized
93
94
95
96
97
98
99
100
101
# File 'lib/jekyll-imgflow/config.rb', line 93defdetermine_version_type(params)ifparams[:width]&&@sizes.value?(params[:width])&&(!params[:format]||@formats.include?(params[:format]))&&(!params[:quality]||params[:quality]==@quality):defaultelse:specializedendend
#docker_config ⇒ Object
71
72
73
74
75
76
77
78
79
80
# File 'lib/jekyll-imgflow/config.rb', line 71defdocker_config{enabled:merged_config.key?("imgproxy_url")||merged_config.key?("weserv_url")||merged_config.key?("flyimg_url"),imgproxy_url:@imgproxy_url,weserv_url:@weserv_url,flyimg_url:@flyimg_url}end
#docker_enabled ⇒ Object
82
83
84
# File 'lib/jekyll-imgflow/config.rb', line 82defdocker_enableddocker_config[:enabled]end
#normalized_input_formats ⇒ Object
Get normalized format lists
129
130
131
# File 'lib/jekyll-imgflow/config.rb', line 129defnormalized_input_formats@input_formats.map(&:downcase)end
#normalized_output_formats ⇒ Object
133
134
135
# File 'lib/jekyll-imgflow/config.rb', line 133defnormalized_output_formats@formats.map(&:downcase)end
#sharp_url ⇒ Object
86
87
88
# File 'lib/jekyll-imgflow/config.rb', line 86defsharp_urlmerged_config["sharp_url"]end
#supported_input_format?(format) ⇒ Boolean
Format validation methods
Returns:
(Boolean)
104
105
106
107
# File 'lib/jekyll-imgflow/config.rb', line 104defsupported_input_format?(format)normalized_format=format.to_s.downcase.delete(".")@input_formats.map(&:downcase).include?(normalized_format)end
#supported_output_format?(format) ⇒ Boolean
Returns:
(Boolean)
109
110
111
112
# File 'lib/jekyll-imgflow/config.rb', line 109defsupported_output_format?(format)normalized_format=format.to_s.downcase.delete(".")@formats.map(&:downcase).include?(normalized_format)end
#validate_input_format!(format) ⇒ Object
Raises:
(ArgumentError)
114
115
116
117
118
119
# File 'lib/jekyll-imgflow/config.rb', line 114defvalidate_input_format!(format)returnifsupported_input_format?(format)raiseArgumentError,"Unsupported input format '#{format}'. Supported formats: #{@input_formats.join(', ')}"end
#validate_output_format!(format) ⇒ Object
Raises:
(ArgumentError)
121
122
123
124
125
126
# File 'lib/jekyll-imgflow/config.rb', line 121defvalidate_output_format!(format)returnifsupported_output_format?(format)raiseArgumentError,"Unsupported output format '#{format}'. Supported formats: #{@formats.join(', ')}"end