set max-width / max-height for random and featured image blocks

This commit is contained in:
Shish 2020-03-28 00:23:29 +00:00
parent b60e8ac5b4
commit 866b77ab19
3 changed files with 19 additions and 15 deletions

View file

@ -77,7 +77,6 @@ function modify_url(string $url, array $changes): string
return unparse_url($parts);
}
/**
* Turn a relative link into an absolute one, including hostname
*/

View file

@ -1,5 +1,8 @@
<?php declare(strict_types=1);
use function MicroHTML\INPUT;
use function MicroHTML\DIV;
use function MicroHTML\A;
use function MicroHTML\IMG;
class FeaturedTheme extends Themelet
{
@ -19,16 +22,21 @@ class FeaturedTheme extends Themelet
public function build_featured_html(Image $image, ?string $query=null): string
{
$i_id = $image->id;
$h_view_link = make_link("post/view/$i_id", $query);
$h_thumb_link = $image->get_thumb_link();
$h_tip = html_escape($image->get_tooltip());
$tsize = get_thumbnail_size($image->width, $image->height);
return "
<a href='$h_view_link'>
<img id='thumb_{$i_id}' title='{$h_tip}' alt='{$h_tip}' class='highlighted' style='height: {$tsize[1]}px; width: {$tsize[0]}px;' src='{$h_thumb_link}'>
</a>
";
return (string)DIV(
["style"=>"text-align: center;"],
A(
["href"=>make_link("post/view/{$image->id}", $query)],
IMG([
"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()
])
)
);
}
}

View file

@ -17,16 +17,13 @@ class RandomImageTheme extends Themelet
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;"
],
["href"=>make_link("post/view/{$image->id}", $query)],
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;",
"style"=>"max-height: {$tsize[1]}px; max-width: 100%;",
"src"=>$image->get_thumb_link()
])
)