I have defined new profile context in sonata_media.yaml:
...
default_context: profile
contexts:
default:
providers:
- sonata.media.provider.dailymotion
- sonata.media.provider.youtube
- sonata.media.provider.image
- sonata.media.provider.file
- sonata.media.provider.vimeo
formats:
small: {width: 100, quality: 70}
big: {width: 500, quality: 70}
profile:
providers:
- sonata.media.provider.image
formats:
small: {width: 90, quality: 70}
big: {width: 90, quality: 70}
...
In my admin class, it's called like this:
$formMapper
->tab('User')
...
->with('Media')
->add('profilePicture', MediaType::class, [
'provider' => 'sonata.media.provider.image',
'context' => 'profile',
'required' => false,
])
->end()
But when image is uploaded, thumbnails are generated in default context folder and dimensions.
There is no error.
Running bin/console sonata:media:fix-media-context doesn't help.
Haha, I found, when an image is uploaded each new upload is done within the same context. I just had to remove picture before upload and my new context is used :) Maybe this post can help another newbie...