-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetIcon.php
More file actions
76 lines (70 loc) · 2.25 KB
/
getIcon.php
File metadata and controls
76 lines (70 loc) · 2.25 KB
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
67
68
69
70
71
72
73
74
75
76
<?php
$fsize = 90; //icon px width in output
$field = 'file'; //name of the field
$pdfImg = 'http://cdn1.iconfinder.com/data/icons/CrystalClear/128x128/mimetypes/pdf.png';
$docImg = 'http://cdn2.iconfinder.com/data/icons/sleekxp/Microsoft%20Office%202007%20Word.png';
$pptImg = 'http://cdn2.iconfinder.com/data/icons/sleekxp/Microsoft%20Office%202007%20PowerPoint.png';
$txtImg = 'http://cdn1.iconfinder.com/data/icons/CrystalClear/128x128/mimetypes/txt2.png';
$xlsImg = 'http://cdn2.iconfinder.com/data/icons/sleekxp/Microsoft%20Office%202007%20Excel.png';
$audioImg = 'http://cdn2.iconfinder.com/data/icons/oxygen/128x128/mimetypes/audio-x-pn-realaudio-plugin.png';
$videoImg = 'http://cdn4.iconfinder.com/data/icons/Pretty_office_icon_part_2/128/video-file.png';
$htmlImg = 'http://cdn1.iconfinder.com/data/icons/nuove/128x128/mimetypes/html.png';
$fileImg = 'http://cdn3.iconfinder.com/data/icons/musthave/128/New.png';
$files = $page->$field;
foreach ($files as $f) {
switch (get_file_extension($f)) {
case 'pdf':
$img = $pdfImg;
break;
case 'doc':
$img = $docImg;
break;
case 'docx':
$img = $docImg;
break;
case 'txt':
$img = $txtImg;
break;
case 'xls':
$img = $xlsImg;
break;
case 'xlsx':
$img = $xlsImg;
break;
case 'xlsm':
$img = $xlsImg;
break;
case 'ppt':
$img = $pptImg;
break;
case 'pptx':
$img = $pptImg;
break;
case 'mp3':
$img = $audioImg;
break;
case 'wmv':
$img = $videoImg;
break;
case 'mp4':
$img = $videoImg;
break;
case 'mpeg':
$img = $videoImg;
break;
case 'html':
$img = $htmlImg;
break;
default:
$img = $fileImg;
break;
}
echo "<a href='{$f->url}' target='_blank'><img src='$img' title='$f' width='$fsize' /></a><p>{$f->description}</p>";
}
function get_file_extension($f) {
$ftype = pathinfo($f);
return $extension = $ftype['extension'];
}
?>
<?php
?>