linkTo($text, $source, ['rel' => 'nofollow']);
} else {
return $this->h($source);
}
}
public function print_preview($post, $options = array())
{
$is_post = $post instanceof Post;
if ($is_post && !CONFIG()->can_see_post(current_user(), $post))
return "";
$image_class = "preview";
!isset($options['url_params']) && $options['url_params'] = null;
$image_id = isset($options['image_id']) ? 'id="'.$options['image_id'].'"' : null;
$image_title = $is_post ? $this->h("Rating: ".$post->pretty_rating()." / Score: ".$post->score." / Tags: ".$this->h($post->cached_tags." / User: ".$post->author())) : null;
$link_onclick = isset($options['onclick']) ? 'onclick="'.$options['onclick'].'"' : null;
$link_onmouseover = isset($options['onmouseover']) ? ' onmouseover="'.$options['onmouseover'].'"' : null;
$link_onmouseout = isset($options['onmouseout']) ? ' onmouseout="'.$options['onmouseout'].'"' : null;
if (isset($options['display']) && $options['display'] == 'block') {
# Show the thumbnail at its actual resolution, and crop it with northern orientation
# to a smaller size.
list($width, $height) = $post->raw_preview_dimensions();
$block_size = array(200, 200);
$visible_width = min(array($block_size[0], $width));
$crop_left = ($width - $visible_width) / 2;
} elseif (isset($options['display']) && $options['display'] == 'large') {
list($width, $height) = $post->raw_preview_dimensions();
$block_size = array($width, $height);
$crop_left = 0;
} else {
# Scale it down to a smaller size. This is exactly one half the actual size, to improve
# resizing quality.
list($width, $height) = $post->preview_dimensions();
$block_size = array(150, 150);
$crop_left = 0;
}
$image = '';
if ($is_post) {
$plid = '#pl http://'.CONFIG()->server_host.'/post/show/'.$post->id.'';
$target_url = '/post/show/' . $post->id . '/' . $post->tag_title() . $options['url_params'];
} else {
$plid = "";
$target_url = $post->url;
}
$link_class = "thumb";
!$is_post && $link_class .= " no-browser-link";
$link = ''.$image.$plid.'';
$div = '
';
$li_class = "";
$ddl_class = "directlink";
if ($post->width >= 3500 || $post->height >= 2600 )
$ddl_class .= " extremeimg";
else
$ddl_class .= ($post->width > 1920 || $post->height > 1500 )? " largeimg":" smallimg";
if ($post->file_ext == "jpg" || $post->file_ext == "jpeg")
$ddl_class .= " file-jpg";
if ($post->file_ext == "png")
$ddl_class .= " file-png";
if ($post->file_ext == "gif")
$ddl_class .= " file-gif";
if ($post->file_ext == "flv" || $post->file_ext == "swf")
$ddl_class .= " file-flv";
if ($post->file_ext == "mp4")
$ddl_class .= " file-mp4";
if ($post->file_ext == "webm")
$ddl_class .= " file-webm";
if ($post->rating == "s")
$ddl_class .= " rating-s";
if ($post->rating == "q")
$ddl_class .= " rating-q";
if ($post->rating == "e")
$ddl_class .= " rating-e";
if (!empty($options['similarity'])) {
$icon = '