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:
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)"} []
http://localhost/Symfony/web/uploads/media/default/0001/01/thumb_1_admin.jpeg
everything is good. the image is displayed without any errors – Ivan