I use IvoryCKEditorBundle in a symfony project without any problems.
But whan I try adding FMElfinderBundle to IvoryCKEditorBundle. I get a blank page with errors in the console:
My code:
#app/config/config.yml
# FMElfinderBundle Configuration
fm_elfinder:
instances:
ckeditor:
locale: %locale% # defaults to current request locale
editor: ckeditor # other options are tinymce, tinymce4, form, custom and simple
fullscreen: true # defaults true, applies to simple and ckeditor editors
theme: smoothness # jquery theme
include_assets: true # disable if you want to handle loading of the javascript and css assets yourself
connector:
debug: false # defaults to false
roots: # at least one root must be defined
uploads:
show_hidden: false # defaults to false
driver: LocalFileSystem
path: uploads
upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
upload_deny: ['all']
upload_max_size: 2M
# IvoryCKEditorBundle Configuration
ivory_ck_editor:
default_config: my_custom_config
configs:
my_custom_config:
toolbar: full
filebrowserBrowseRoute: elfinder
filebrowserBrowseRouteParameters:
instance: ckeditor
Any help?? thanks
This is my config. Maybe it helps:
fm_elfinder:
instances:
default:
locale: %default_locale% # defaults to current request locale
editor: ckeditor # other options are tinymce, tinymce4, form, custom and simple
fullscreen: true # defaults true, applies to simple and ckeditor editors
theme: smoothness # jquery theme
include_assets: true # disable if you want to handle loading of the javascript and css assets yourself
connector:
debug: false # defaults to false
roots: # at least one root must be defined
uploads:
show_hidden: false # defaults to false
driver: LocalFileSystem
path: uploads/content
upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
upload_deny: ['all']
upload_max_size: 20M
ivory_ck_editor:
configs:
my_config:
removePlugins: 'flash,print,forms,div,newpage'
allowedContent: true
entities: false
autoParagraph: false
protectedSource: ['/<span[^>]*><\/span>/g', '/<i[^>]*><\/i>/g']
Seems that elfinder assets didn't properly dumped, check assets folder under web root directory. Also check that your composer file contains
{
"config": {
"component-dir": "web/assets"
}
}
This part tell component installer to copy assets under web/assets directory.
Related
I use FMElfinderBundle to upload image in my blog.
But, when I want to "Browse server" in order to upload image, I get a blank page with this errors:
enter image description here
#config/packages/fm_elfinder.yaml
fm_elfinder:
assets_path: "/public/uploads/images/post_img" # Le dossier configuré dans composer.json
instances:
ckeditor:
locale: "%locale%"
editor: "ckeditor"
fullscreen: false
include_assets: true
connector:
debug: false
roots:
uploads:
driver: "LocalFileSystem"
path: "/public/uploads/images/post_img"
upload_allow: ['image/png', 'image/jpg', 'image/jpeg', 'image/gif', 'application/zip', 'audio/mpeg', 'text/csv', 'video/mp4', 'video/webm', 'application/pdf']
upload_deny: ['all']
upload_max_size: "8M"
Thank you for help!
I have a problem with the Sonata Media bundle. Images that i upload on server (local) are not displayed (thumbnail missing). I checked the path and it's all correct. All images that I uploaded is transferred to the directory /web/ uploads/media .
Check Screenshot:
Full size screenshot here
Config File:
sonata_media:
# if you don't use default namespace configuration
#class:
# media: MyVendor\MediaBundle\Entity\Media
# gallery: MyVendor\MediaBundle\Entity\Gallery
# gallery_has_media: MyVendor\MediaBundle\Entity\GalleryHasMedia
default_context: default
db_driver: doctrine_orm # or doctrine_mongodb, doctrine_phpcr
contexts:
default: # the default context is mandatory
providers:
- sonata.media.provider.dailymotion
- sonata.media.provider.youtube
- sonata.media.provider.image
- sonata.media.provider.file
formats:
preview: { width: 100, quality: 100}
small: { width: 100 , quality: 70}
big: { width: 500 , quality: 70}
cdn:
server:
path: uploads/media
filesystem:
local:
directory: %kernel.root_dir%/../web/uploads/media
create: false
sonata_notification:
backend: sonata.notification.backend.runtime
sonata_notification:
admin:
enabled: false
Am using Media bundle in Sonata admin bundle like this and all work good but just that thumbnail is not rendered. I read Media BUndle doc Helper section but dont understand.
In my ArticleAdmin controlir i adding filend like this:
/**
* Configure Form Fields
*
* Fields to be shown on create/edit forms
*/
protected function configureFormFields(FormMapper $formMapper)
{
$link_parameters = array();
if ($this->hasParentFieldDescription()) {
$link_parameters = $this->getParentFieldDescription()->getOption('link_parameters', array());
}
if ($this->hasRequest()) {
$context = $this->getRequest()->get('context', null);
if (null !== $context) {
$link_parameters['context'] = $context;
}
}
$formMapper->add('media', 'sonata_type_model_list', array('required' => false), array(
'link_parameters' => $link_parameters
))
}
Any solution?
UPDATE:
In my log file, I found this :
[2015-01-22 15:28:22] request.ERROR: Uncaught PHP Exception
Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No
route found for "GET
/admin/sonata/media/media/uploads/media/default/0001/01/thumb_1_admin.jpeg""
at C:\xampp\htdocs\Symfony\app\cache\dev\classes.php line 2017
{"exception":"[object]
(Symfony\Component\HttpKernel\Exception\NotFoundHttpException(code:
0): No route found for \"GET
/admin/sonata/media/media/uploads/media/default/0001/01/thumb_1_admin.jpeg\"
at C:\xampp\htdocs\Symfony\app\cache\dev\classes.php:2017,
Symfony\Component\Routing\Exception\ResourceNotFoundException(code:
0): at
C:\xampp\htdocs\Symfony\app\cache\dev\appDevUrlMatcher.php:521)"}
[]
Your link should be something like '/uploads/media/....' and not 'upload/media/...'
In your config file, change
cdn:
server:
path: uploads/media
to
cdn:
server:
path: /uploads/media
Hope it helps to solve your problem.
In addition to Stiff Roy answer, you can set your virtual host root to Symfony/web (in your case).
So when you will be on http://localhost/app_dev.php/admin/sonata/media/media/list
your images load as http://localhost/uploads/media/default/0001/01/thumb.jpg
Error "No route found for "GET /admin/sonata/media/media/uploads/media/default/0001/01/thumb_1_admin.jpeg"" says that it tried to load an image through controller and not by the direct access. Additional info about setting your env could be found here or here (PHP Storm).
need to change the path in config.yml
sonata_media
cdn:
server:
path: /myproject/web/uploads/media
ok so I solved the problem this way:
sonata_media:
# if you don't use default namespace configuration
#class:
# media: MyVendor\MediaBundle\Entity\Media
# gallery: MyVendor\MediaBundle\Entity\Gallery
# gallery_has_media: MyVendor\MediaBundle\Entity\GalleryHasMedia
db_driver: doctrine_orm # or doctrine_mongodb, doctrine_phpcr it is mandatory to choose one here
default_context: default # you need to set a context
contexts:
default: # the default context is mandatory
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}
cdn:
server:
path: "/uploads/media" # http://media.sonata-project.org/
filesystem:
local:
directory: "%kernel.root_dir%/../web/uploads/media"
create: false
and in the console : $php app/console server:start
The symphony environment app_dev is not working with the sonata media bundle.
Cheers
I am using LiipImageBundle & KNP Gaufrette bundle to resize & load images from s3. It was all working before but suddenly it stopped working. There are no bundle version upgrades.
Below is my configuration,
liip_imagine:
cache: aws_s3_images
data_loader: stream.aws_s3_images
filter_sets:
large:
quality: 75
cache: aws_s3_images
data_loader: stream.aws_s3_images
filters:
relative_resize: { widen: 140 }
medium:
quality: 75
cache: aws_s3_images
data_loader: stream.aws_s3_images
filters:
thumbnail: { size: [50, 50], mode: outbound }
small:
quality: 75
cache: aws_s3_images
data_loader: stream.aws_s3_images
filters:
thumbnail: { size: [25, 25], mode: outbound }
loaders:
stream.aws_s3_images:
stream:
wrapper: gaufrette://aws_s3_images_fs/
knp_gaufrette:
adapters:
aws_s3_images_adapter:
aws_s3:
service_id: 'st.aws_s3.client'
bucket_name: %amazon.s3.bucket%
options:
#directory: 'fos'
create: true
filesystems:
aws_s3_images_fs:
adapter: aws_s3_images_adapter
stream_wrapper: ~
The problem is strange, if I open image in new tab, it redirects to s3 image url and displays image. Once it loads in new tab, then it starts displaying normally. It doesnt work unless I open it new new tab.
is it not resolving s3 path ? What could be the issue ? I tried deleting all cache, I don't have media folder in my web directory.
In log it shows ImagineController:FilterAction is called.
In html source image path is
http://st.com/app_dev.php/media/cache/resolve/large/fos/user/ebc36103e6d1038791eb7eca2f4449db0780fdf41416235134.jpeg
Now if I open it in new tab/window, it will redirect to
[MY_S3_BUCKET_URL]/fos/user/large/ebc36103e6d1038791eb7eca2f4449db0780fdf41416235134.jpeg
and will display image in new window.
Now if I again refresh my page, image source is now changed to
[MY_S3_BUCKET_URL]/fos/user/large/ebc36103e6d1038791eb7eca2f4449db0780fdf41416235134.jpeg
and now I can see image loaded ?
Why it started happening suddenly. It was all working properly before.
After going through all the code of LiipImaginBundle & debugging, it turned out to be content type issue which was caused by FOSRestBundle's
format_listener:
rules:
- { path: '^/', priorities: [ '*/*' ], fallback_format: html, prefer_extension: true }
Changing it to
format_listener:
rules:
- { path: '^/', priorities: [ 'html', '*/*' ], fallback_format: html, prefer_extension: true }
fixed the issue.
I managed to run the upload images via WYSIWYG CKEditor using SonataMediaBundle and CoopTilleulsCKEditorSonataMediaBundle.
The Upload works very well for ADMIN users, but does not work for users with the USER_ROLE,
Do you know how can I resolve that? thank you very much
Thank you !
config.yml
# SonataMediaBundle
sonata_media:
class:
media: Application\Sonata\MediaBundle\Entity\Media
gallery: Application\Sonata\MediaBundle\Entity\Gallery
gallery_has_media: Application\Sonata\MediaBundle\Entity\GalleryHasMedia
default_context: default
db_driver: doctrine_orm # or doctrine_mongodb, doctrine_phpcr
contexts:
default: # the default context is mandatory
download:
strategy: sonata.media.security.connected_strategy
mode: http
providers:
- sonata.media.provider.dailymotion
- sonata.media.provider.youtube
- sonata.media.provider.image
- sonata.media.provider.file
formats:
small: { width: 100 , quality: 70}
big: { width: 500 , quality: 70}
news:
download:
strategy: sonata.media.security.connected_strategy
mode: http
providers:
- sonata.media.provider.youtube
- sonata.media.provider.image
formats:
small: { width: 80 , quality: 70}
big: { width: 500 , quality: 90}
cdn:
server:
path: /uploads/media # http://media.sonata-project.org/
filesystem:
local:
directory: %kernel.root_dir%/../web/uploads/media
create: false
providers:
image:
service: sonata.media.provider.image
resizer: sonata.media.resizer.simple # sonata.media.resizer.square
filesystem: sonata.media.filesystem.local
cdn: sonata.media.cdn.server
generator: sonata.media.generator.default
thumbnail: sonata.media.thumbnail.format
allowed_extensions: ['jpg', 'png', 'jpeg']
allowed_mime_types: ['image/pjpeg', 'image/jpeg', 'image/png', 'image/x-png']
# FOSRestBundle
fos_rest:
view:
formats:
json: true
# CmfCreateBundle
cmf_create:
object_mapper_service_id: cmf_create.persistence.orm.object_mapper
# IvoryCKEditorBundle
ivory_ck_editor:
configs:
user_config:
toolbar: [ [ 'Cut','Copy','Paste','PasteText','PasteFromWord']
filebrowserUploadRoute: admin_sonata_media_media_upload
filebrowserBrowseRoute: admin_sonata_media_media_browser
filebrowserImageBrowseRoute: admin_sonata_media_media_browser
# Display images by default when clicking the image dialog browse button
filebrowserImageBrowseRouteParameters:
provider: sonata.media.provider.image
filebrowserUploadRoute: admin_sonata_media_media_upload
filebrowserUploadRouteParameters:
provider: sonata.media.provider.file
# Upload file as image when sending a file from the image dialog
filebrowserImageUploadRoute: admin_sonata_media_media_upload
filebrowserImageUploadRouteParameters:
provider: sonata.media.provider.image
context: news # Optional, to upload in a custom contexta custom context
admin_config:
toolbar: full
uiColor: "#000000"
filebrowserBrowseRoute: admin_sonata_media_media_browser
filebrowserImageBrowseRoute: admin_sonata_media_media_browser
# Display images by default when clicking the image dialog browse button
filebrowserImageBrowseRouteParameters:
provider: sonata.media.provider.image
filebrowserUploadRoute: admin_sonata_media_media_upload
filebrowserUploadRouteParameters:
provider: sonata.media.provider.file
# Upload file as image when sending a file from the image dialog
filebrowserImageUploadRoute: admin_sonata_media_media_upload
filebrowserImageUploadRouteParameters:
provider: sonata.media.provider.image
context: news # Optional, to upload in a custom contexta custom context
This error occurs when I add new image to gallery.
The filter "number_format_decimal" does not exist in
SonataMediaBundle:MediaAdmin:edit.html.twig at line 54
my config
//app/conf/config.yml
sonata_media:
# if you don't use default namespace configuration
#class:
# media: MyVendor\MediaBundle\Entity\Media
# gallery: MyVendor\MediaBundle\Entity\Gallery
# gallery_has_media: MyVendor\MediaBundle\Entity\GalleryHasMedia
default_context: default
db_driver: doctrine_orm # or doctrine_mongodb, doctrine_phpcr
contexts:
default: # the default context is mandatory
providers:
- sonata.media.provider.dailymotion
- sonata.media.provider.youtube
- sonata.media.provider.image
- sonata.media.provider.file
formats:
small: { width: 100 , quality: 70}
big: { width: 500 , quality: 70}
cdn:
server:
path: /uploads/media # http://media.sonata-project.org/
filesystem:
local:
directory: %kernel.root_dir%/../web/uploads/media
create: false
The problem is on the sonata media bundle use "2.2.8" not "dev-master" on your composer.json and run php composer.phar update
We fixed the issue, see https://github.com/sonata-project/SonataMediaBundle/commit/352ef71a872fa3f8db1f095569bf68fe0733eafc for more information
Working well with
composer.json
"sonata-project/media-bundle": "2.2.*#dev"