From f373ead95fb5beb962c376b5b7b46dfde8ac4e57 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Mon, 23 Feb 2026 22:57:27 -0500 Subject: update website to work with crimson framework --- src/web/lib/image.php | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 src/web/lib/image.php (limited to 'src/web/lib/image.php') diff --git a/src/web/lib/image.php b/src/web/lib/image.php new file mode 100644 index 0000000..7b6ec0e --- /dev/null +++ b/src/web/lib/image.php @@ -0,0 +1,96 @@ +', + $mime, $path, $media); +} + +function image( + $name, + $alt, + $formats = array('webp', 'png'), + $animated = FALSE, + $attrs = array(), + + $height = NULL, + $width = NULL, + $size = NULL) :string +{ + + if ($animated === TRUE) { + $animated = array('gif'); + } + + if (!$animated) { + $animated = array(); + } + + $out = ""; + + foreach ($formats as $format) { + $media = count($animated) ? '(prefers-reduced-motion: reduce)' : NULL; + $out .= __make_source($name, $format, $media); + } + + foreach ($animated as $format) { + $out .= __make_source($name, $format, NULL); + } + + $format = end($formats); + $path = Base::get_url('public/' . $name . '.' . $format, TRUE); + $out .= " $value) { + $out .= " $key=\"$value\""; + } + $out .= '>'; + + return $out; +} -- cgit v1.2.3-freya