2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2023-01-10 22:44:09 +00:00
|
|
|
|
|
|
|
namespace Shimmie2;
|
|
|
|
|
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
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
class RandomImageTheme extends Themelet
|
|
|
|
{
|
2024-01-15 14:23:00 +00:00
|
|
|
public function display_random(Page $page, Image $image): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2020-10-26 15:17:15 +00:00
|
|
|
$page->add_block(new Block("Random Post", $this->build_random_html($image), "left", 8));
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2012-01-27 07:22:38 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
public function build_random_html(Image $image, ?string $query = null): string
|
|
|
|
{
|
|
|
|
$tsize = get_thumbnail_size($image->width, $image->height);
|
2012-01-27 07:22:38 +00:00
|
|
|
|
2020-01-28 21:19:59 +00:00
|
|
|
return (string)DIV(
|
2023-11-11 21:49:12 +00:00
|
|
|
["style" => "text-align: center;"],
|
2020-01-28 21:19:59 +00:00
|
|
|
A(
|
2023-11-11 21:49:12 +00:00
|
|
|
["href" => make_link("post/view/{$image->id}", $query)],
|
2020-01-28 21:19:59 +00:00
|
|
|
IMG([
|
2023-11-11 21:49:12 +00:00
|
|
|
"id" => "thumb_rand_{$image->id}",
|
|
|
|
"title" => $image->get_tooltip(),
|
|
|
|
"alt" => $image->get_tooltip(),
|
|
|
|
"class" => 'highlighted',
|
|
|
|
"style" => "max-height: {$tsize[1]}px; max-width: 100%;",
|
|
|
|
"src" => $image->get_thumb_link()
|
2020-01-28 21:19:59 +00:00
|
|
|
])
|
|
|
|
)
|
|
|
|
);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-01-16 08:18:15 +00:00
|
|
|
}
|