black-lamp / yii2-file-icons
Widget for getting the font-icon for file extension
Installs: 977
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 1
Type:yii2-extension
Requires
- php: >=5.6.0
- yiisoft/yii2: ^2.0.4
Requires (Dev)
This package is not auto-updated.
Last update: 2024-11-10 03:07:03 UTC
README
Widget for getting the font-icon for file extension
Installation
Run command
composer require black-lamp/yii2-file-icons
or add
"black-lamp/yii2-file-icons": "^1.0.0"
to the require section of your composer.json.
Using
Example of using
$widget = \bl\files\icons\FileIconWidget::begin([ 'icons' => [ 'txt' => [ 'icon' => \yii\helpers\Html::tag('i', '', ['class' => 'icon-file-txt']) ], 'groups' => [ [ 'extensions' => ['jpg', 'png', 'gif'], 'icon' => \yii\helpers\Html::tag('i', '', ['class' => 'icon-picture']) ], ] ] ]); echo $widget->getIcon('image.jpg'); $widget->end();
Method FileIconWidget::getIcon()
takes file extension, file name or full path to file and returns
icon for file extension. Icon - method gets from configuration array. If icon not found in configuration array
method returns empty icon. Empty icon value gets from emptyIcon
widget option.
Widget configuration properties
Default icon set
If you set widget option useDefaultIcons
in true
- method FileIconWidget::getIcon()
will be returns
default icons for file extensions. Also you can override default icons if you dont't wont to use default icon
for curren file extension.
<i class="file-text"></i> <i class="file-pdf"></i> <i class="file-power-point"></i> <i class="file-archive"></i> <i class="file-word"></i> <i class="file-excel"></i> <i class="file-picture"></i> <i class="file-video"></i> <i class="file-code"></i>
or using \bl\files\icons\helpers\IconHelper
IconHelper::icon('text'); IconHelper::icon('pdf'); IconHelper::icon('power-point'); IconHelper::icon('archive'); IconHelper::icon('word'); IconHelper::icon('excel'); IconHelper::icon('picture'); IconHelper::icon('video'); IconHelper::icon('code');