This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/random_image/theme.php

36 lines
1.2 KiB
PHP
Raw Normal View History

2020-01-26 13:19:35 +00:00
<?php declare(strict_types=1);
2020-01-29 00:49:21 +00:00
use function MicroHTML\DIV;
use function MicroHTML\A;
use function MicroHTML\IMG;
2009-01-16 08:18:15 +00:00
class RandomImageTheme extends Themelet
{
public function display_random(Page $page, Image $image)
{
$page->add_block(new Block("Random Image", $this->build_random_html($image), "left", 8));
}
public function build_random_html(Image $image, ?string $query = null): string
{
$tsize = get_thumbnail_size($image->width, $image->height);
return (string)DIV(
["style"=>"text-align: center;"],
A(
[
"href"=>make_link("post/view/{$image->id}", $query),
"style"=>"position: relative; height: {$tsize[1]}px; width: {$tsize[0]}px;"
],
IMG([
"id"=>"thumb_rand_{$image->id}",
"title"=>$image->get_tooltip(),
"alt"=>$image->get_tooltip(),
"class"=>'highlighted',
"style"=>"height: {$tsize[1]}px; width: {$tsize[0]}px;",
"src"=>$image->get_thumb_link()
])
)
);
}
2009-01-16 08:18:15 +00:00
}