coopTilleuls / CoopTilleulsCKEditorSonataMediaBundle

Integrates SonataMediaBundle for Symfony with CKEditor
http://les-tilleuls.coop
MIT License
53 stars 41 forks source link

Using specified format on upload? #4

Closed jrdnrc closed 10 years ago

jrdnrc commented 10 years ago

Hi,

Is it possible to use a specified format automatically when uploading images? For example, I upload high res images, which aren't suitable for displaying inline in a web page, and Sonata Media Bundle resizes them to small, medium, and large. Is it possible to have it use the medium size as soon as the image is uploaded?

Cheers

dunglas commented 10 years ago

You can specify a context at upload time. This is explained in the documentation: https://github.com/coopTilleuls/CoopTilleulsCKEditorSonataMediaBundle/blob/master/Resources/doc/architecture.md

More about contexts: http://sonata-project.org/bundles/media/master/doc/reference/media_context.html

jrdnrc commented 10 years ago

Yeah, I'm aware you can specify a context. I also want to specify a format for the image to use by default though, eg small/medium/large/whatever else I have defined.

Cheers

Sent from my iPhone

On 12 Nov 2013, at 19:25, Kévin Dunglas notifications@github.com wrote:

You can specify a context. This is explained in the documentation: https://github.com/coopTilleuls/CoopTilleulsCKEditorSonataMediaBundle/blob/master/Resources/doc/architecture.md

More about contexts: http://sonata-project.org/bundles/media/master/doc/reference/media_context.html

— Reply to this email directly or view it on GitHub.

meyerbaptiste commented 10 years ago

You can add a persistent parameter, then filter the formats array in browserAction (https://github.com/coopTilleuls/CoopTilleulsCKEditorSonataMediaBundle/blob/master/Controller/MediaAdminController.php#L58L61) and change the links to the media reference URL by your configured default format in the template browser.html.twig. It's an idea but maybe not the cleanest.

dunglas commented 10 years ago

From what I know, there is no way to specify a default format for a context in SonataMediaBundle. But you can override SonataMediaBundle to add this feature in your application to fit your needs.