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/themes/rule34v2/themelet.class.php
2020-03-13 09:23:54 +00:00

39 lines
1.6 KiB
PHP

<?php
class Themelet extends BaseThemelet
{
public function build_thumb_html(Image $image): string
{
global $cache, $config;
$cached = $cache->get("thumb-block:{$image->id}");
if ($cached) {
return $cached;
}
$i_id = (int) $image->id;
$h_view_link = make_link('post/view/'.$i_id);
$h_image_link = $image->get_image_link();
$h_thumb_link = $image->get_thumb_link();
$h_tip = html_escape($image->get_tooltip());
$h_tags = strtolower($image->get_tag_list());
$h_ext = strtolower($image->ext);
// If file is flash or svg then sets thumbnail to max size.
if ($image->ext === 'swf' || $image->ext === 'svg') {
$tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height'));
} else {
$tsize = get_thumbnail_size($image->width, $image->height);
}
$html = "<div class='shm-thumb thumb' data-ext=\"$h_ext\" data-tags=\"$h_tags\" data-post-id=\"$i_id\"><a class='shm-thumb-link' href='$h_view_link'>".
'<img id="thumb_'.$i_id.'" title="'.$h_tip.'" alt="'.$h_tip.'" height="'.$tsize[1].'" width="'.$tsize[0].'" src="'.$h_thumb_link.'" loading="lazy"></a>'.
'<br><a href="'.$h_image_link.'">Image Only</a>'.
"<span class='need-del'> - <a href='#' onclick='image_hash_ban($i_id); return false;'>Ban</a></span>".
"</div>\n";
// cache for ages; will be cleared in ext/index:onImageInfoSet
$cache->set("thumb-block:{$image->id}", $html, 86400);
return $html;
}
}