-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathq2a-thumbnail-in-list-layer.php
66 lines (60 loc) · 1.34 KB
/
q2a-thumbnail-in-list-layer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
class qa_html_theme_layer extends qa_html_theme_base
{
public function head_css()
{
qa_html_theme_base::head_css();
$css = "
/* 質問リストのサムネイル */
.qa-q-item-thmub {
margin: 0 0 0 10px;
width:120px;
height:90px;
overflow:hidden;
position:relative;
float: left;
}
.qa-q-item-thmub img {
max-width:140%;
min-width:100%;
width:auto;
min-height:100%;
max-height:140%;
height:auto;
position:absolute;
top:-40%;
right:-40%;
bottom:-40%;
left:-40%;
margin:auto;
}
";
$this->output('<style>', $css, '</style>');
}
public function q_list_item($q_item)
{
$this->output('<div class="qa-q-list-item'.rtrim(' '.@$q_item['classes']).'" '.@$q_item['tags'].'>');
$this->q_item_stats($q_item);
$this->q_item_thumbnail($q_item);
$this->q_item_main($q_item);
$this->q_item_clear();
$this->output('</div> <!-- END qa-q-list-item -->', '');
}
function q_item_thumbnail($q_item)
{
$thumbnail = $this->get_thumbnail($q_item['raw']['postid']);
if (!empty($thumbnail)) {
$this->output(
'<div class="qa-q-item-thmub">',
'<img '. $thumbnail. ' width="120" height="90" />',
'</div>'
);
}
}
function get_thumbnail($postid)
{
$post = qa_db_single_select(qa_db_full_post_selectspec(null, $postid));
preg_match("/<img(.+?)>/", $post['content'], $matches);
return $matches[1];
}
}