X-Git-Url: https://git.bts.cx/cx.git/blobdiff_plain/6e68608aecb6a542b9c75a13afd5002aeb7bc0f1..9a60ead9e861fcb9c8fb252e4b27aa36d28b7954:/cx/lib/images.php?ds=sidebyside diff --git a/cx/lib/images.php b/cx/lib/images.php index fd6d622..dbe55bf 100644 --- a/cx/lib/images.php +++ b/cx/lib/images.php @@ -58,11 +58,30 @@ function cx_images_get(int $limit = 0) { $sql .= ';'; foreach (cx_db_query($sql) as $image) { - $p = new Image($image); - yield $p; + $i = new Image($image); + yield $i; } } +function cx_images_find_image($image_id) { + $sql = 'SELECT + image_id, + image_uid, + image_type, + image_alt_text + FROM images + WHERE image_id == ? + OR image_uid LIKE ? + LIMIT 1;'; + + foreach (cx_db_query($sql, $image_id, $image_id . "%") as $image) { + $i = new Image($image); + return $i; + } + + return null; +} + cx_setup_register(1, function() { cx_db_exec('CREATE TABLE images ( image_id INTEGER PRIMARY KEY,