diff options
| author | Freya Murphy <freya@freyacat.org> | 2026-02-23 22:57:27 -0500 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2026-02-23 22:57:27 -0500 |
| commit | f373ead95fb5beb962c376b5b7b46dfde8ac4e57 (patch) | |
| tree | c99df23521ff2a5e5e2e4627c525a5e99dc2e3ae /src/web/helpers/image.php | |
| parent | add 96x96 logo (diff) | |
| download | website-f373ead95fb5beb962c376b5b7b46dfde8ac4e57.tar.gz website-f373ead95fb5beb962c376b5b7b46dfde8ac4e57.tar.bz2 website-f373ead95fb5beb962c376b5b7b46dfde8ac4e57.zip | |
update website to work with crimson framework
Diffstat (limited to 'src/web/helpers/image.php')
| -rw-r--r-- | src/web/helpers/image.php | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/src/web/helpers/image.php b/src/web/helpers/image.php deleted file mode 100644 index d4683fe..0000000 --- a/src/web/helpers/image.php +++ /dev/null @@ -1,94 +0,0 @@ -<?php /* Copyright (c) 2024 Freya Murphy */ - -function __get_mime($type) -{ - switch ($type) { - case 'mp4': - return 'video/mp4'; - case 'webm': - return 'video/webm'; - case 'gif': - return 'image/gif'; - case 'png': - return 'image/png'; - case 'jpg': - return 'image/jpeg'; - case 'webp': - return 'image/webp'; - default: - return NULL; - } -} - -function __make_source( - $name, - $format, - $media) -{ - if ($media) { - $media = "media=\"$media\""; - } else { - $media = ''; - } - $path = Core::get_url('public/' . $name . '.' . $format, TRUE); - $mime = __get_mime($format); - return sprintf('<source type="%s" srcset="%s" %s>', - $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 = "<picture>"; - - 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 = Core::get_url('public/' . $name . '.' . $format, TRUE); - $out .= "<img src=\"$path\""; - if ($alt) { - $alt = lang($alt); - $attrs['alt'] = $alt; - $attrs['title'] = $alt; - } - if ($width) { - $attrs['width'] = $width; - } - if ($height) { - $attrs['height'] = $height; - } - if ($size) { - $attrs['width'] = $size; - $attrs['height'] = $size; - } - foreach ($attrs as $key => $value) { - $out .= " $key=\"$value\""; - } - $out .= '></picture>'; - - return $out; -} |