Keyword

About k2 attachments

  • Meridies web
  • Meridies web's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 2 weeks ago #157656 by Meridies web
Replied by Meridies web on topic About k2 attachments
I done this my way, i hope its good way.
_________________________


<?php

$mystring = $attachment->filename;
//var_dump($attachment);
$findme = '.';
$pos = strpos($mystring, $findme);

// Note our use of ===. Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
if ($pos === false) {
echo '<i class="fa fa-file-word-o" aria-hidden="true"></i>&nbsp';//default icon

} else {
$ext = end(explode('.',$mystring));

switch ($ext){
case 'doc':
case 'docx':
echo'<i class="fa fa-file-word-o fa-lg" aria-hidden="true"></i>&nbsp';//word icon
break;
case 'pdf':
echo'<i class="fa fa-file-pdf-o fa-lg" aria-hidden="true"></i>&nbsp';//pdf icon
break;
case 'xls':
case 'xlsx':
echo'<i class="fa fa-file-excel-o fa-lg" aria-hidden="true"></i>&nbsp';//excel icon
break;
case 'odt':
case 'txt':
case 'xml':
case 'rtf':
echo'<i class="fa fa-file-o fa-lg" aria-hidden="true"></i>&nbsp';//excel icon
break;
//and more
default:
break;
}

}
?>

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 2 weeks ago #157659 by Krikor Boghossian
Replied by Krikor Boghossian on topic About k2 attachments
Yes, it is a really nice solution :)

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum