【问题标题】:Preview image in sonata media bundle in configureFormFields在 configureFormFields 中的奏鸣曲媒体包中预览图像
【发布时间】:2017-09-03 10:34:45
【问题描述】:

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

这-> https://symfony.com/doc/master/bundles/SonataAdminBundle/cookbook/recipe_image_previews.html 没有工作 返回

试图调用类的名为“getWebPath”的未定义方法...

【问题讨论】:

  • 请在问题正文中包含所有相关信息。我们不仅更容易提供帮助,而且在链接失效时确保问题对所有访问者仍然有效,并且帖子可能会被删除。谢谢。

标签: php symfony sonata-admin sonata


【解决方案1】:

您必须在实体 Image 类中实现 getWebPath 方法(查看pre-requisites),类似于:

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

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

【讨论】:

    猜你喜欢
    • 2017-11-22
    • 2013-12-04
    • 2017-11-17
    • 2015-09-30
    • 2014-06-04
    • 1970-01-01
    • 2018-07-05
    • 2018-10-30
    • 2018-12-08
    相关资源
    最近更新 更多