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

40 lines
986 B
PHP
Raw Normal View History

2009-01-16 08:18:15 +00:00
<?php
2014-04-29 21:45:13 +00:00
class RandomImageTheme extends Themelet
{
/**
* @param Page $page
* @param Image $image
*/
public function display_random(Page $page, Image $image)
{
$page->add_block(new Block("Random Image", $this->build_random_html($image), "left", 8));
}
2014-04-29 21:45:13 +00:00
/**
* @param Image $image
* @param null|string $query
* @return string
*/
public function build_random_html(Image $image, $query = null)
{
2014-04-29 21:45:13 +00:00
$i_id = int_escape($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);
2014-04-29 21:45:13 +00:00
return "
2014-04-28 07:26:35 +00:00
<center><div>
2014-04-28 07:26:35 +00:00
<a href='$h_view_link' style='position: relative; height: {$tsize[1]}px; width: {$tsize[0]}px;'>
<img id='thumb_rand_$i_id' title='$h_tip' alt='$h_tip' class='highlighted' style='height: {$tsize[1]}px; width: {$tsize[0]}px;' src='$h_thumb_link'>
</a>
</div></center>
";
2009-01-16 08:18:15 +00:00
}
}