在 configureFormFields 中预览奏鸣曲媒体包中的图像

Preview image in sonata media bundle in configureFormFields

如何在奏鸣曲管理包的媒体字段中制作预览图像?

这-> https://symfony.com/doc/master/bundles/SonataAdminBundle/cookbook/recipe_image_previews.html 无效 Return

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

您必须在您的实体图像中实现 getWebPath 方法 class(查看 pre-requisites),例如:

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

public function getWebPath()
{
    return null === $this->path
        ? 'null'
        : $this->getUploadDir().'/'.$this->path;
}