class

Hwaro::Content::Hooks::ImageHooks

Inherits Hwaro::Core::Lifecycle::Hookable / Reference / Object

Constants

CONCURRENCY = 8

Max number of concurrent image processing fibers

Class methods

find_closest(url : String, width : Int32) : String | Nil
Source
find_lqip(url : String) : Hash(String, String) | Nil
Source
find_resized(url : String, width : Int32) : String | Nil
Source
lqip_map
Source
resize_map

Returns a snapshot copy of the resize map (safe to use outside mutex)

Source
resize_map_readonly

Read-only access to the resize map for the render phase. The map is populated once by the BeforeRender image:resize hook and is never mutated during rendering, so render workers can read it directly instead of paying a full .dup of the (potentially large, site-wide) map per image-bearing page and serializing on the mutex. Concurrent reads of the unmutated Hash under -Dpreview_mt are safe.

Source
reusable_widths(source_path : String, dest_dir : String, widths : Array(Int32)) : Hash(Int32, String) | Nil

Returns a width => filename map when every expected destination file already exists on disk with an mtime at least as new as the source (i.e. decoding/resizing would produce bit-identical output). Returns nil when any destination is missing, stale, or empty — caller then processes the image normally. Empty is checked so a killed serve mid-write doesn't leave a zero-byte file that would pass an mtime check and get served as a broken image.

Caller must also verify LQIP cache separately; LQIP can't be reconstructed from disk bytes.

Source
set_lqip_map(map : Hash(String, Hash(String, String)))
Source
set_resize_map(map : Hash(String, Hash(Int32, String)))

Replace the resize map (used by tests)

Source

Instance methods

register_hooks(manager : Core::Lifecycle::Manager)
Source