Skip to content

Commit 13e0b26

Browse files
committed
add image preview in view
1 parent 0130de2 commit 13e0b26

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Parsers/HTMLInputs/File.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22

33
namespace EasyPanel\Parsers\HTMLInputs;
44

5+
use Illuminate\Support\Str;
6+
57
class File
68
{
79

810
public function handle($name)
911
{
10-
return "<input type='file' wire:model='$name' class=\"form-control-file @error('$name') is-invalid @enderror\" id='input$name'>";
12+
$string = '$'.$name;
13+
return "<input type='file' wire:model='$name' class=\"form-control-file @error('$name') is-invalid @enderror\" id='input$name'>
14+
@if($string and !".'$errors'."->has('$name') and $string instanceof \Livewire\TemporaryUploadedFile and (in_array( ".$string."->guessExtension(), ['png', 'jpg', 'gif', 'jpeg'])))
15+
<a href=\"{{ ".$string."->temporaryUrl() }}\"><img width=\"200\" height=\"200\" class=\"img-fluid shadow\" src=\"{{ ".$string."->temporaryUrl() }}\" alt=\"\"></a>
16+
@endif";
1117
}
1218
}

0 commit comments

Comments
 (0)