File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 1
1
<div class =" {{ $field -> divClass ?? ' col-6' } }" >
2
2
@include (' livewire-forms::fields.label' )
3
+
3
4
@if ($field -> getValue () )
4
5
<img
5
6
class =" {{ $field -> class ?? ' img-fluid' } }"
6
- src =" {{ optional ( $ field-> getValue ()) -> getFormatOrOriginal ( $field -> format ) } }"
7
+ src =" {{ isset ( $files_ [ $ field-> getName ()]) ? $files_ [ $field -> getName ()] -> temporaryUrl () : $field -> getValue () } }"
7
8
alt =" {{ $field -> altText ?? optional ($field -> getValue ())-> name } }"
8
9
id =" {{ $field -> getName () } }"
9
- wire:model =" files.{{ $field -> getName () } }"
10
10
>
11
11
@endif
12
+ <input
13
+ type =" file"
14
+ class =" {{ $field -> class } }"
15
+ id =" {{ $field -> getName () } }"
16
+ name =" {{ $field -> getName () } }"
17
+ placeholder =" {{ $field -> getLabel () } }"
18
+ wire:model =" files.{{ $field -> getName () } }"
19
+ >
12
20
@include (' livewire-forms::fields.error' )
13
21
</div >
Original file line number Diff line number Diff line change 3
3
namespace Codedor \LivewireForms \Fields ;
4
4
5
5
use Codedor \Media \Models \Attachment ;
6
+ use Livewire \TemporaryUploadedFile ;
6
7
7
8
class ImageField extends Field
8
9
{
9
10
public $ component = 'livewire-forms::fields.image ' ;
10
11
11
12
public $ value = false ;
12
13
14
+ public $ containsFile = true ;
15
+
13
16
public function getValue ($ doConditionalChecks = false )
14
17
{
18
+
15
19
$ value = parent ::getValue ($ doConditionalChecks );
16
20
17
21
if ($ value === '' ) {
18
22
return $ value ;
19
23
}
20
24
21
25
if (Attachment::find ($ value )) {
22
- return Attachment::find ($ value );
26
+ return Attachment::find ($ value )-> getFormatOrOriginal ( $ this -> format ?? '' ) ;
23
27
}
24
28
25
29
return $ value ;
26
30
}
31
+
27
32
}
You can’t perform that action at this time.
0 commit comments