filament / spatie-laravel-media-library-plugin
Filament support for `spatie/laravel-medialibrary`.
Requires
- php: ^8.1
- illuminate/support: ^10.45|^11.0
- spatie/laravel-medialibrary: ^10.0|^11.0
- 3.x-dev
- v3.2.124
- v3.2.123
- v3.2.122
- v3.2.121
- v3.2.120
- v3.2.119
- v3.2.118
- v3.2.117
- v3.2.116
- v3.2.115
- v3.2.114
- v3.2.113
- v3.2.112
- v3.2.111
- v3.2.110
- v3.2.109
- v3.2.108
- v3.2.107
- v3.2.106
- v3.2.105
- v3.2.104
- v3.2.103
- v3.2.102
- v3.2.101
- v3.2.100
- v3.2.99
- v3.2.98
- v3.2.97
- v3.2.96
- v3.2.95
- v3.2.94
- v3.2.93
- v3.2.92
- v3.2.91
- v3.2.90
- v3.2.89
- v3.2.88
- v3.2.87
- v3.2.87-beta1
- v3.2.86
- v3.2.85
- v3.2.84
- v3.2.83
- v3.2.82
- v3.2.81
- v3.2.80
- v3.2.79
- v3.2.78
- v3.2.77
- v3.2.76
- v3.2.75
- v3.2.74
- v3.2.73
- v3.2.72
- v3.2.71
- v3.2.70
- v3.2.69
- v3.2.68
- v3.2.67
- v3.2.66
- v3.2.65
- v3.2.64
- v3.2.63
- v3.2.62
- v3.2.61
- v3.2.60
- v3.2.59
- v3.2.58
- v3.2.57
- v3.2.56
- v3.2.55
- v3.2.54
- v3.2.53
- v3.2.52
- v3.2.51
- v3.2.50
- v3.2.49
- v3.2.48
- v3.2.47
- v3.2.46
- v3.2.45
- v3.2.44
- v3.2.43
- v3.2.42
- v3.2.41
- v3.2.40
- v3.2.39
- v3.2.38
- v3.2.37
- v3.2.36
- v3.2.35
- v3.2.34
- v3.2.33
- v3.2.32
- v3.2.31
- v3.2.30
- v3.2.29
- v3.2.28
- v3.2.27
- v3.2.26
- v3.2.25
- v3.2.25-beta1
- v3.2.24
- v3.2.23
- v3.2.22
- v3.2.21
- v3.2.20
- v3.2.19
- v3.2.18
- v3.2.17
- v3.2.16
- v3.2.15
- v3.2.14
- v3.2.13
- v3.2.12
- v3.2.11
- v3.2.10
- v3.2.9
- v3.2.8
- v3.2.7
- v3.2.6
- v3.2.5
- v3.2.4
- v3.2.3
- v3.2.2
- v3.2.1
- v3.2.0
- v3.1.47
- v3.1.46
- v3.1.45
- v3.1.44
- v3.1.43
- v3.1.42
- v3.1.41
- v3.1.40
- v3.1.39
- v3.1.38
- v3.1.37
- v3.1.36
- v3.1.35
- v3.1.34
- v3.1.33
- v3.1.32
- v3.1.31
- v3.1.30
- v3.1.29
- v3.1.28
- v3.1.27
- v3.1.26
- v3.1.25
- v3.1.24
- v3.1.23
- v3.1.22
- v3.1.21
- v3.1.20
- v3.1.19
- v3.1.18
- v3.1.17
- v3.1.16
- v3.1.15
- v3.1.14
- v3.1.13
- v3.1.12
- v3.1.11
- v3.1.10
- v3.1.9
- v3.1.8
- v3.1.7
- v3.1.6
- v3.1.5
- v3.1.4
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1.0
- v3.1.0-alpha4
- v3.1.0-alpha3
- v3.1.0-alpha2
- v3.1.0-alpha1
- v3.0.103
- v3.0.102
- v3.0.101
- v3.0.100
- v3.0.99
- v3.0.98
- v3.0.97
- v3.0.96
- v3.0.95
- v3.0.94
- v3.0.93
- v3.0.92
- v3.0.91
- v3.0.90
- v3.0.89
- v3.0.88
- v3.0.87
- v3.0.86
- v3.0.85
- v3.0.84
- v3.0.83
- v3.0.82
- v3.0.81
- v3.0.80
- v3.0.79
- v3.0.78
- v3.0.77
- v3.0.76
- v3.0.75
- v3.0.74
- v3.0.73
- v3.0.72
- v3.0.71
- v3.0.70
- v3.0.69
- v3.0.68
- v3.0.67
- v3.0.66
- v3.0.65
- v3.0.64
- v3.0.63
- v3.0.62
- v3.0.61
- v3.0.60
- v3.0.59
- v3.0.58
- v3.0.57
- v3.0.56
- v3.0.55
- v3.0.54
- v3.0.53
- v3.0.52
- v3.0.51
- v3.0.50
- v3.0.49
- v3.0.48
- v3.0.47
- v3.0.46
- v3.0.45
- v3.0.44
- v3.0.43
- v3.0.42
- v3.0.41
- v3.0.40
- v3.0.39
- v3.0.38
- v3.0.37
- v3.0.36
- v3.0.35
- v3.0.34
- v3.0.33
- v3.0.32
- v3.0.31
- v3.0.30
- v3.0.29
- v3.0.28
- v3.0.27
- v3.0.26
- v3.0.25
- v3.0.24
- v3.0.23
- v3.0.22
- v3.0.21
- v3.0.20
- v3.0.19
- v3.0.18
- v3.0.17
- v3.0.16
- v3.0.15
- v3.0.14
- v3.0.13
- v3.0.12
- v3.0.11
- v3.0.10
- v3.0.9
- v3.0.8
- v3.0.7
- v3.0.6
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v3.0.0-beta28
- v3.0.0-beta27
- v3.0.0-beta26
- v3.0.0-beta25
- v3.0.0-beta24
- v3.0.0-beta23
- v3.0.0-beta22
- v3.0.0-beta21
- v3.0.0-beta20
- v3.0.0-beta19
- v3.0.0-beta18
- v3.0.0-beta17
- v3.0.0-beta16
- v3.0.0-beta15
- v3.0.0-beta14
- v3.0.0-beta13
- v3.0.0-beta12
- v3.0.0-beta11
- v3.0.0-beta10
- v3.0.0-beta9
- v3.0.0-beta8
- v3.0.0-beta7
- v3.0.0-beta6
- v3.0.0-beta5
- v3.0.0-beta4
- v3.0.0-beta3
- v3.0.0-beta2
- v3.0.0-beta1
- v3.0.0-alpha137
- v3.0.0-alpha136
- v3.0.0-alpha135
- v3.0.0-alpha132
- v3.0.0-alpha131
- v3.0.0-alpha130
- v3.0.0-alpha129
- v3.0.0-alpha128
- v3.0.0-alpha127
- v3.0.0-alpha126
- v3.0.0-alpha125
- v3.0.0-alpha124
- v3.0.0-alpha123
- v3.0.0-alpha122
- v3.0.0-alpha121
- v3.0.0-alpha120
- v3.0.0-alpha119
- v3.0.0-alpha118
- v3.0.0-alpha117
- v3.0.0-alpha116
- v3.0.0-alpha115
- v3.0.0-alpha114
- v3.0.0-alpha113
- v3.0.0-alpha112
- v3.0.0-alpha111
- v3.0.0-alpha110
- v3.0.0-alpha109
- v3.0.0-alpha108
- v3.0.0-alpha107
- v3.0.0-alpha106
- v3.0.0-alpha105
- v3.0.0-alpha104
- v3.0.0-alpha103
- v3.0.0-alpha102
- v3.0.0-alpha101
- v3.0.0-alpha100
- v3.0.0-alpha99
- v3.0.0-alpha98
- v3.0.0-alpha97
- v3.0.0-alpha96
- v3.0.0-alpha95
- v3.0.0-alpha94
- v3.0.0-alpha93
- v3.0.0-alpha92
- v3.0.0-alpha91
- v3.0.0-alpha90
- v3.0.0-alpha89
- v3.0.0-alpha88
- v3.0.0-alpha87
- v3.0.0-alpha86
- v3.0.0-alpha85
- v3.0.0-alpha84
- v3.0.0-alpha83
- v3.0.0-alpha82
- v3.0.0-alpha81
- v3.0.0-alpha80
- v3.0.0-alpha79
- v3.0.0-alpha78
- v3.0.0-alpha77
- v3.0.0-alpha76
- v3.0.0-alpha75
- v3.0.0-alpha74
- v3.0.0-alpha73
- v3.0.0-alpha72
- v3.0.0-alpha71
- v3.0.0-alpha70
- v3.0.0-alpha69
- v3.0.0-alpha68
- v3.0.0-alpha67
- v3.0.0-alpha66
- v3.0.0-alpha65
- v3.0.0-alpha64
- v3.0.0-alpha63
- v3.0.0-alpha62
- v3.0.0-alpha61
- v3.0.0-alpha60
- v3.0.0-alpha59
- v3.0.0-alpha58
- v3.0.0-alpha57
- v3.0.0-alpha56
- v3.0.0-alpha55
- v3.0.0-alpha54
- v3.0.0-alpha53
- v3.0.0-alpha52
- v3.0.0-alpha51
- v3.0.0-alpha50
- v3.0.0-alpha49
- v3.0.0-alpha48
- v3.0.0-alpha47
- v3.0.0-alpha46
- v3.0.0-alpha45
- v3.0.0-alpha44
- v3.0.0-alpha43
- v3.0.0-alpha42
- v3.0.0-alpha41
- v3.0.0-alpha40
- v3.0.0-alpha39
- v3.0.0-alpha38
- v3.0.0-alpha37
- v3.0.0-alpha36
- v3.0.0-alpha35
- v3.0.0-alpha34
- v3.0.0-alpha33
- v3.0.0-alpha32
- v3.0.0-alpha31
- v3.0.0-alpha30
- v3.0.0-alpha29
- v3.0.0-alpha28
- v3.0.0-alpha27
- v3.0.0-alpha26
- v3.0.0-alpha25
- v3.0.0-alpha24
- v3.0.0-alpha23
- v3.0.0-alpha10
- v3.0.0-alpha9
- v3.0.0-alpha8
- v3.0.0-alpha7
- v3.0.0-alpha6
- v3.0.0-alpha5
- v3.0.0-alpha4
- v3.0.0-alpha3
- v3.0.0-alpha2
- v3.0.0-alpha1
- 2.x-dev
- v2.17.56
- v2.17.55
- v2.17.54
- v2.17.53
- v2.17.52
- v2.17.51
- v2.17.50
- v2.17.49
- v2.17.48
- v2.17.47
- v2.17.46
- v2.17.45
- v2.17.44
- v2.17.43
- v2.17.42
- v2.17.41
- v2.17.40
- v2.17.39
- v2.17.38
- v2.17.37
- v2.17.36
- v2.17.35
- v2.17.34
- v2.17.32
- v2.17.31
- v2.17.30
- v2.17.29
- v2.17.28
- v2.17.27
- v2.17.26
- v2.17.25
- v2.17.24
- v2.17.23
- v2.17.22
- v2.17.21
- v2.17.20
- v2.17.19
- v2.17.18
- v2.17.17
- v2.17.16
- v2.17.15
- v2.17.14
- v2.17.13
- v2.17.12
- v2.17.11
- v2.17.10
- v2.17.9
- v2.17.8
- v2.17.7
- v2.17.6
- v2.17.5
- v2.17.4
- v2.17.3
- v2.17.2
- v2.17.1
- v2.17.0
- v2.16.70
- v2.16.69
- v2.16.68
- v2.16.67
- v2.16.66
- v2.16.65
- v2.16.64
- v2.16.63
- v2.16.62
- v2.16.61
- v2.16.60
- v2.16.59
- v2.16.58
- v2.16.57
- v2.16.56
- v2.16.55
- v2.16.54
- v2.16.53
- v2.16.52
- v2.16.51
- v2.16.50
- v2.16.49
- v2.16.48
- v2.16.47
- v2.16.46
- v2.16.45
- v2.16.44
- v2.16.43
- v2.16.42
- v2.16.41
- v2.16.40
- v2.16.39
- v2.16.38
- v2.16.37
- v2.16.36
- v2.16.35
- v2.16.34
- v2.16.33
- v2.16.32
- v2.16.31
- v2.16.29
- v2.16.28
- v2.16.27
- v2.16.26
- v2.16.25
- v2.16.24
- v2.16.23
- v2.16.22
- v2.16.21
- v2.16.20
- v2.16.19
- v2.16.18
- v2.16.17
- v2.16.16
- v2.16.15
- v2.16.14
- v2.16.13
- v2.16.12
- v2.16.11
- v2.16.10
- v2.16.9
- v2.16.8
- v2.16.7
- v2.16.6
- v2.16.5
- v2.16.4
- v2.16.3
- v2.16.2
- v2.16.1
- v2.16.0
- v2.15.49
- v2.15.48
- v2.15.47
- v2.15.46
- v2.15.45
- v2.15.44
- v2.15.43
- v2.15.42
- v2.15.41
- v2.15.40
- v2.15.39
- v2.15.38
- v2.15.37
- v2.15.36
- v2.15.35
- v2.15.34
- v2.15.33
- v2.15.32
- v2.15.31
- v2.15.30
- v2.15.29
- v2.15.28
- v2.15.27
- v2.15.26
- v2.15.25
- v2.15.24
- v2.15.23
- v2.15.22
- v2.15.21
- v2.15.20
- v2.15.19
- v2.15.19-beta1
- v2.15.18
- v2.15.17
- v2.15.16
- v2.15.15
- v2.15.14
- v2.15.13
- v2.15.12
- v2.15.11
- v2.15.10
- v2.15.9
- v2.15.8
- v2.15.7
- v2.15.6
- v2.15.5
- v2.15.4
- v2.15.3
- v2.15.2
- v2.15.1
- v2.15.0
- v2.14.5
- v2.14.4
- v2.14.3
- v2.14.2
- v2.14.1
- v2.14.0
- v2.13.28
- v2.13.27
- v2.13.26
- v2.13.25
- v2.13.24
- v2.13.23
- v2.13.22
- v2.13.21
- v2.13.20
- v2.13.19
- v2.13.18
- v2.13.17
- v2.13.16
- v2.13.15
- v2.13.14
- v2.13.13
- v2.13.12
- v2.13.11
- v2.13.10
- v2.13.9
- v2.13.8
- v2.13.7
- v2.13.6
- v2.13.5
- v2.13.4
- v2.13.3
- v2.13.2
- v2.13.1
- v2.13.0
- v2.13.0-beta1
- v2.12.31
- v2.12.30
- v2.12.29
- v2.12.28
- v2.12.27
- v2.12.26
- v2.12.25
- v2.12.24
- v2.12.23
- v2.12.22
- v2.12.21
- v2.12.20
- v2.12.19
- v2.12.18
- v2.12.17
- v2.12.16
- v2.12.15
- v2.12.14
- v2.12.13
- v2.12.12
- v2.12.11
- v2.12.10
- v2.12.9
- v2.12.8
- v2.12.7
- v2.12.6
- v2.12.5
- v2.12.4
- v2.12.3
- v2.12.2
- v2.12.1
- v2.12.0
- v2.12.0-beta8
- v2.12.0-beta7
- v2.12.0-beta6
- v2.12.0-beta5
- v2.12.0-beta4
- v2.12.0-beta3
- v2.12.0-beta2
- v2.12.0-beta1
- v2.11.12
- v2.11.11
- v2.11.10
- v2.11.9
- v2.11.8
- v2.11.7
- v2.11.6
- v2.11.5
- v2.11.4
- v2.11.3
- v2.11.2
- v2.11.1
- v2.11.0
- v2.10.46
- v2.10.45
- v2.10.44
- v2.10.43
- v2.10.42
- v2.10.41
- v2.10.40
- v2.10.39
- v2.10.38
- v2.10.37
- v2.10.36
- v2.10.35
- v2.10.34
- v2.10.33
- v2.10.32
- v2.10.31
- v2.10.30
- v2.10.29
- v2.10.28
- v2.10.27
- v2.10.26
- v2.10.25
- v2.10.24
- v2.10.23
- v2.10.22
- v2.10.21
- v2.10.20
- v2.10.19
- v2.10.18
- v2.10.17
- v2.10.16
- v2.10.15
- v2.10.14
- v2.10.13
- v2.10.12
- v2.10.11
- v2.10.10
- v2.10.9
- v2.10.8
- v2.10.7
- v2.10.6
- v2.10.5
- v2.10.4
- v2.10.3
- v2.10.2
- v2.10.1
- v2.10.0
- v2.10.0-beta1
- v2.9.19
- v2.9.18
- v2.9.17
- v2.9.16
- v2.9.15
- v2.9.14
- v2.9.13
- v2.9.12
- v2.9.11
- v2.9.10
- v2.9.9
- v2.9.8
- v2.9.7
- v2.9.6
- v2.9.5
- v2.9.4
- v2.9.3
- v2.9.2
- v2.9.1
- v2.9.0
- v2.8.11
- v2.8.10
- v2.8.9
- v2.8.8
- v2.8.7
- v2.8.6
- v2.8.5
- v2.8.4
- v2.8.3
- v2.8.2
- v2.8.1
- v2.8.0
- v2.7.17
- v2.7.16
- v2.7.15
- v2.7.14
- v2.7.13
- v2.7.12
- v2.7.11
- v2.7.10
- v2.7.9
- v2.7.8
- v2.7.7
- v2.7.6
- v2.7.5
- v2.7.4
- v2.7.3
- v2.7.2
- v2.7.1
- v2.7.0
- v2.6.6
- v2.6.5
- v2.6.4
- v2.6.3
- v2.6.2
- v2.6.1
- v2.6.0
- v2.5.31
- v2.5.30
- v2.5.29
- v2.5.28
- v2.5.27
- v2.5.26
- v2.5.25
- v2.5.24
- v2.5.23
- v2.5.22
- v2.5.21
- v2.5.20
- v2.5.19
- v2.5.18
- v2.5.17
- v2.5.16
- v2.5.15
- v2.5.14
- v2.5.13
- v2.5.12
- v2.5.11
- v2.5.10
- v2.5.9
- v2.5.8
- v2.5.7
- v2.5.6
- v2.5.5
- v2.5.4
- v2.5.3
- v2.5.2
- v2.5.1
- v2.5.0
- v2.5.0-beta2
- v2.5.0-beta1
- v2.4.58
- v2.4.57
- v2.4.56
- v2.4.55
- v2.4.54
- v2.4.53
- v2.4.52
- v2.4.51
- v2.4.50
- v2.4.49
- v2.4.48
- v2.4.47
- v2.4.46
- v2.4.45
- v2.4.44
- v2.4.43
- v2.4.42
- v2.4.41
- v2.4.40
- v2.4.39
- v2.4.38
- v2.4.37
- v2.4.36
- v2.4.35
- v2.4.34
- v2.4.33
- v2.4.32
- v2.4.31
- v2.4.30
- v2.4.29
- v2.4.28
- v2.4.27
- v2.4.26
- v2.4.25
- v2.4.24
- v2.4.23
- v2.4.22
- v2.4.21
- v2.4.20
- v2.4.19
- v2.4.18
- v2.4.17
- v2.4.16
- v2.4.15
- v2.4.14
- v2.4.13
- v2.4.12
- v2.4.11
- v2.4.10
- v2.4.9
- v2.4.8
- v2.4.7
- v2.4.6
- v2.4.5
- v2.4.4
- v2.4.3
- v2.4.2
- v2.4.1
- v2.4.0
- v2.4.0-beta3
- v2.4.0-beta2
- v2.4.0-beta1
- v2.3.6
- v2.3.5
- v2.3.4
- v2.3.3
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.4
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.14
- v2.0.13
- v2.0.12
- v2.0.11
- v2.0.10
- v2.0.9
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v2.0.0-beta30
- v2.0.0-beta29
- v2.0.0-beta28
- v2.0.0-beta27
- v2.0.0-beta26
- v2.0.0-beta25
- v2.0.0-beta24
- v2.0.0-beta23
- v2.0.0-beta22
- v2.0.0-beta21
- v2.0.0-beta20
- v2.0.0-beta19
- v2.0.0-beta18
- v2.0.0-beta17
- v2.0.0-beta16
- v2.0.0-beta15
- v2.0.0-beta14
- v2.0.0-beta13
- v2.0.0-beta12
- v2.0.0-beta11
- v2.0.0-beta10
- v2.0.0-beta9
- v2.0.0-beta8
- v2.0.0-beta7
- v2.0.0-beta6
- v2.0.0-beta5
- v2.0.0-beta4
- v2.0.0-beta3
- v2.0.0-beta2
- dev-3.x-alpha
This package is auto-updated.
Last update: 2024-11-13 16:35:38 UTC
README
Installation
Install the plugin with Composer:
composer require filament/spatie-laravel-media-library-plugin:"^3.2" -W
If you haven't already done so, you need to publish the migration to create the media table:
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="medialibrary-migrations"
Run the migrations:
php artisan migrate
You must also prepare your Eloquent model for attaching media.
For more information, check out Spatie's documentation.
Form component
You may use the field in the same way as the original file upload field:
use Filament\Forms\Components\SpatieMediaLibraryFileUpload; SpatieMediaLibraryFileUpload::make('avatar')
The media library file upload supports all the customization options of the original file upload component.
The field will automatically load and save its uploads to your model. To set this functionality up, you must also follow the instructions set out in the setting a form model section. If you're using a panel, you can skip this step.
Passing a collection
Optionally, you may pass a collection()
allows you to group files into categories:
use Filament\Forms\Components\SpatieMediaLibraryFileUpload; SpatieMediaLibraryFileUpload::make('avatar') ->collection('avatars')
Configuring the storage disk and directory
By default, files will be uploaded publicly to your storage disk defined in the Filament configuration file. You can also set the FILAMENT_FILESYSTEM_DISK
environment variable to change this. This is to ensure consistency between all Filament packages. Spatie's disk configuration will not be used, unless you define a disk for a registered collection.
Alternatively, you can manually set the disk with the disk()
method:
use Filament\Forms\Components\FileUpload; FileUpload::make('attachment') ->disk('s3')
The base file upload component also has configuration options for setting the directory()
and visibility()
of uploaded files. These are not used by the media library file upload component. Spatie's package has its own system for determining the directory of a newly-uploaded file, and it does not support uploading private files out of the box. One way to store files privately is to configure this in your S3 bucket settings, in which case you should also use visibility('private')
to ensure that Filament generates temporary URLs for your files.
Reordering files
In addition to the behavior of the normal file upload, Spatie's Media Library also allows users to reorder files.
To enable this behavior, use the reorderable()
method:
use Filament\Forms\Components\SpatieMediaLibraryFileUpload; SpatieMediaLibraryFileUpload::make('attachments') ->multiple() ->reorderable()
You may now drag and drop files into order.
Adding custom properties
You may pass in custom properties when uploading files using the customProperties()
method:
use Filament\Forms\Components\SpatieMediaLibraryFileUpload; SpatieMediaLibraryFileUpload::make('attachments') ->multiple() ->customProperties(['zip_filename_prefix' => 'folder/subfolder/'])
Adding custom headers
You may pass in custom headers when uploading files using the customHeaders()
method:
use Filament\Forms\Components\SpatieMediaLibraryFileUpload; SpatieMediaLibraryFileUpload::make('attachments') ->multiple() ->customHeaders(['CacheControl' => 'max-age=86400'])
Generating responsive images
You may generate responsive images when the files are uploaded using the responsiveImages()
method:
use Filament\Forms\Components\SpatieMediaLibraryFileUpload; SpatieMediaLibraryFileUpload::make('attachments') ->multiple() ->responsiveImages()
Using conversions
You may also specify a conversion()
to load the file from showing it in the form, if present:
use Filament\Forms\Components\SpatieMediaLibraryFileUpload; SpatieMediaLibraryFileUpload::make('attachments') ->conversion('thumb')
Storing conversions on a separate disk
You can store your conversions and responsive images on a disk other than the one where you save the original file. Pass the name of the disk where you want conversion to be saved to the conversionsDisk()
method:
use Filament\Forms\Components\SpatieMediaLibraryFileUpload; SpatieMediaLibraryFileUpload::make('attachments') ->conversionsDisk('s3')
Storing media-specific manipulations
You may pass in manipulations that are run when files are uploaded using the manipulations()
method:
use Filament\Forms\Components\SpatieMediaLibraryFileUpload; SpatieMediaLibraryFileUpload::make('attachments') ->multiple() ->manipulations([ 'thumb' => ['orientation' => '90'], ])
Filtering media
It's possible to target a file upload component to only handle a certain subset of media in a collection. To do that, you can filter the media collection using the filterMediaUsing()
method. This method accepts a function that receives the $media
collection and manipulates it. You can use any collection method to filter it.
For example, you could scope the field to only handle media that has certain custom properties:
use Filament\Forms\Components\SpatieMediaLibraryFileUpload; use Filament\Forms\Get; use Illuminate\Support\Collection; SpatieMediaLibraryFileUpload::make('images') ->customProperties(fn (Get $get): array => [ 'gallery_id' => $get('gallery_id'), ]) ->filterMediaUsing( fn (Collection $media, Get $get): Collection => $media->where( 'custom_properties.gallery_id', $get('gallery_id') ), )
Table column
To use the media library image column:
use Filament\Tables\Columns\SpatieMediaLibraryImageColumn; SpatieMediaLibraryImageColumn::make('avatar')
The media library image column supports all the customization options of the original image column.
Passing a collection
Optionally, you may pass a collection()
:
use Filament\Tables\Columns\SpatieMediaLibraryImageColumn; SpatieMediaLibraryImageColumn::make('avatar') ->collection('avatars')
The collection allows you to group files into categories.
By default, only media without a collection (using the default
collection) will be shown. If you want to show media from all collections, you can use the allCollections()
method:
use Filament\Tables\Columns\SpatieMediaLibraryImageColumn; SpatieMediaLibraryImageColumn::make('avatar') ->allCollections()
Using conversions
You may also specify a conversion()
to load the file from showing it in the table, if present:
use Filament\Tables\Columns\SpatieMediaLibraryImageColumn; SpatieMediaLibraryImageColumn::make('avatar') ->conversion('thumb')
Filtering media
It's possible to target the column to only display a subset of media in a collection. To do that, you can filter the media collection using the filterMediaUsing()
method. This method accepts a function that receives the $media
collection and manipulates it. You can use any collection method to filter it.
For example, you could scope the column to only display media that has certain custom properties:
use Filament\Tables\Columns\SpatieMediaLibraryImageColumn; use Illuminate\Support\Collection; SpatieMediaLibraryImageColumn::make('images') ->filterMediaUsing( fn (Collection $media): Collection => $media->where( 'custom_properties.gallery_id', 12345, ), )
Infolist entry
To use the media library image entry:
use Filament\Infolists\Components\SpatieMediaLibraryImageEntry; SpatieMediaLibraryImageEntry::make('avatar')
The media library image entry supports all the customization options of the original image entry.
Passing a collection
Optionally, you may pass a collection()
:
use Filament\Infolists\Components\SpatieMediaLibraryImageEntry; SpatieMediaLibraryImageEntry::make('avatar') ->collection('avatars')
The collection allows you to group files into categories.
By default, only media without a collection (using the default
collection) will be shown. If you want to show media from all collections, you can use the allCollections()
method:
use Filament\Infolists\Components\SpatieMediaLibraryImageEntry; SpatieMediaLibraryImageEntry::make('avatar') ->allCollections()
Using conversions
You may also specify a conversion()
to load the file from showing it in the infolist, if present:
use Filament\Infolists\Components\SpatieMediaLibraryImageEntry; SpatieMediaLibraryImageEntry::make('avatar') ->conversion('thumb')
Filtering media
It's possible to target the entry to only display a subset of media in a collection. To do that, you can filter the media collection using the filterMediaUsing()
method. This method accepts a function that receives the $media
collection and manipulates it. You can use any collection method to filter it.
For example, you could scope the entry to only display media that has certain custom properties:
use Filament\Tables\Columns\SpatieMediaLibraryImageEntry; use Illuminate\Support\Collection; SpatieMediaLibraryImageEntry::make('images') ->filterMediaUsing( fn (Collection $media): Collection => $media->where( 'custom_properties.gallery_id', 12345, ), )