Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions config/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@

],

/*
|--------------------------------------------------------------------------
| Default Container
|--------------------------------------------------------------------------
|
| When adding Assets fields to blueprints, Statamic will use this container
| as the default. You can override this setting on a field-by-field basis.
| Changing this value may break existing asset relationships.
|
*/

'default_container' => 'assets',

/*
|--------------------------------------------------------------------------
| Auto-Crop Assets
Expand Down
5 changes: 5 additions & 0 deletions src/Fieldtypes/AssetContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ public function augmentValue($value)
{
return Facades\AssetContainer::find($value);
}

public function defaultValue()
{
return config('statamic.assets.default_container');
}
}
1 change: 0 additions & 1 deletion src/Fieldtypes/Assets/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ protected function configFieldItems(): array
'max_items' => 1,
'mode' => 'select',
'required' => true,
'default' => AssetContainer::all()->count() == 1 ? AssetContainer::all()->first()->handle() : null,
'force_in_config' => true,
'width' => '50',
],
Expand Down
2 changes: 1 addition & 1 deletion tests/Auth/HasAvatarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function setUp(): void

private function withAvatarField()
{
$blueprint = Blueprint::makeFromFields(['avatar' => ['type' => 'assets', 'max_files' => 1]]);
$blueprint = Blueprint::makeFromFields(['avatar' => ['type' => 'assets', 'max_files' => 1, 'container' => 'avatars']]);

BlueprintRepository::shouldReceive('find')->with('user')->andReturn($blueprint);

Expand Down
1 change: 1 addition & 0 deletions tests/Fieldtypes/AssetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ public function fieldtype($config = [])
{
return (new Assets)->setField(new Field('test', array_merge([
'type' => 'assets',
'container' => 'test',
], $config)));
}

Expand Down