简体   繁体   English

Symfony2 Sonata媒体捆绑定制图像裁剪

[英]Symfony2 Sonata Media Bundle Custom Image Cropping

It seems that Sonata Media has only two strategies when it comes to cropping/resizing the uploaded image, Sonata\\MediaBundle\\Resizer\\SimpleResizer and Sonata\\MediaBundle\\Resizer\\SquareResizer. 在裁剪/调整上载图像的大小时,Sonata Media似乎只有两种策略:Sonata \\ MediaBundle \\ Resizer \\ SimpleResizer和Sonata \\ MediaBundle \\ Resizer \\ SquareResizer。 Both these strategies are automatic, meaning that the users don't have a say in how they want the image to be resized/croppped. 这两种策略都是自动的,这意味着用户对于如何调整图像大小/裁剪没有发言权。

I would like to give the user an option to select the portion of the image that is more relevant, kind like the jQuery Image Cropper library used by GenemuFormBundle, but I don't even know where to start. 我想给用户一个选项,以选择更相关的图像部分,类似于GenemuFormBundle使用的jQuery Image Cropper库,但我什至不知道从哪里开始。 Will I need to create my own Admin class instead of using Sonata\\MediaBundle\\Admin\\BaseMediaAdmin? 我是否需要创建自己的管理员类,而不是使用Sonata \\ MediaBundle \\ Admin \\ BaseMediaAdmin? Has anyone write a bundle that I can use? 有没有人写我可以使用的捆绑软件? How do you manage your galleries usually? 您通常如何管理画廊?

在此处输入图片说明

You should look at ComurImageBundle . 您应该看看ComurImageBundle It's far easier than Sonata Media, doesn't create anything in database and lets you upload with jquery file uploader, crop with jcrop and other useful things. 它比Sonata Media容易得多,它不会在数据库中创建任何内容,而使您可以使用jquery文件上传器进行上传,使用jcrop进行裁剪和其他有用的操作。

在此处输入图片说明

I wrote a simple admin extension that give you the ability to customize the images by format. 我写了一个简单的管理员扩展,使您能够按格式自定义图像。 It's actually a Work In Progress that needs some test, documentation and refactoring, but it does the job, it's lightweight and it's shipped with a resizer to handle fixed dimensions. 它实际上是一个进行中的工作,需要进行一些测试,文档编制和重构,但它确实可以完成工作,它是轻量级的,并且随附有用于调整固定尺寸的调整器。

You can find it here: https://github.com/julien-maitan/sonata-media-crop 您可以在这里找到它: https : //github.com/julien-maitan/sonata-media-crop

If you are using sonata media bundle with sonata admin, there is a picasa photo editor already in place in media edit form. 如果您将Sonata媒体捆绑包与Sonata管理员一起使用,则媒体编辑表单中已经有一个picasa照片编辑器。

Please check. 请检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM