Skip to content

Commit

Permalink
Update FileBehavior.php
Browse files Browse the repository at this point in the history
  • Loading branch information
dmkdesign authored Sep 13, 2023
1 parent 67899cc commit e83ca75
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions src/behaviors/FileBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,25 +125,44 @@ public function getInitialPreviewConfig()

foreach ($this->getFiles() as $index => $file) {
if(str_contains($file->mime,"image"))
{
$initialPreviewConfig[] = [
'type'=>'image',
{
$initialPreviewConfig[] = [
'caption' => "$file->name.$file->type",
'url' => Url::toRoute(['/attachments/file/delete',
'id' => $file->id
]),
'id' => $file->id])
];
}
else
{
$initialPreviewConfig[] = [
'type'=>$file->type,
}
elseif(str_contains($file->mime,"text")){
$initialPreviewConfig[] = [
'type'=> "text",
'caption' => "$file->name.$file->type",
'url' => Url::toRoute(['/attachments/file/delete',
'id' => $file->id])
];
}
elseif(str_contains($file->mime,"video")){
$initialPreviewConfig[] = [
'type'=> "video",
'caption' => "$file->name.$file->type",
'url' => Url::toRoute(['/attachments/file/delete',
'id' => $file->id])
];
}
elseif(str_contains($file->mime,"doc")||str_contains($file->mime,".ppt")||str_contains($file->mime,".xls")){
$initialPreviewConfig[] = [
'type'=> "office",
'caption' => "$file->name.$file->type",
'url' => Url::toRoute(['/attachments/file/delete',
'id' => $file->id])
];
}
else{
$initialPreviewConfig[] = [
'type'=> $file->type,
'caption' => "$file->name.$file->type",
'url' => Url::toRoute(['/attachments/file/delete',
'id' => $file->id
]),
'id' => $file->id])
];

}
}
return $initialPreviewConfig;
Expand Down

0 comments on commit e83ca75

Please sign in to comment.