Create Attachment Viewer Links
Create links to freely available plugins/applications for attachment files based upon the attachment MIME type.
<?php // Create viewer link based on an attachment mime type
$download='';
switch (true) {
case (stristr($post->post_mime_type,'pdf')):
$download = '<a href="http://www.adobe.com/products/acrobat/readstep2.html">Adobe Acrobat Reader</a>';
break;
case (stristr($post->post_mime_type,'msword')):
$download = 'Microsoft<sup>®</sup> Word or <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=95e24c87-8732-48d5-8689-ab826e7b8fdf">Word Viewer 2003</a>';
break;
case (stristr($post->post_mime_type,'excel')):
$download = 'Microsoft<sup>®</sup> Excel or <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c8378bf4-996c-4569-b547-75edbd03aaf0">Excel Viewer 2003</a>';
break;
case (stristr($post->post_mime_type,'powerpoint')):
$download = 'Microsoft<sup>®</sup> Powerpoint or <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=428D5727-43AB-4F24-90B7-A94784AF71A4">Powerpoint Reader</a>';
break;
case (stristr($post->post_mime_type,'quicktime')):
$download = '<a href="http://www.apple.com/quicktime/download/">Quicktime</a>';
break;
}
if($download !='') echo '<p><small>This file requires '.$download.'.</small></p>';
?>
Output Example
This file requires Adobe Acrobat Reader
You might also be interested in
Scrapbook 5.2 - Russian translation