-1

How make preview image in media fields in sonata admin bundle ?

This-> https://symfony.com/doc/master/bundles/SonataAdminBundle/cookbook/recipe_image_previews.html no working Return

Attempted to call an undefined method named "getWebPath" of class ...

webwinner
  • 87
  • 2
  • 8
  • Please include all relevant info within the body of the question. Not only is it easier for us to help, but ensures the question remains valid for all visitors if the links become invalid, and post may be subject to deletion. Thanks. – SherylHohman Sep 23 '17 at 01:49

1 Answers1

0

you must implement a getWebPath method in your entity Image class (look at pre-requisites), something like:

protected function getUploadDir()
{
    return '/uploads';
}

public function getWebPath()
{
    return null === $this->path
        ? 'null'
        : $this->getUploadDir().'/'.$this->path;
}
T. Abdelmalek
  • 418
  • 3
  • 10