symfony2のSonataAdminBundleで画像を表示させたい場合
twigを呼び出して使うようです
How to display the current picture above the upload field in SonataAdminBundle?
Adminクラス側で、templateオプションを指定
protected function configureListFields(ListMapper $list) { $list->addIdentifier("name") ->add('picture', NULL, array('template' => 'MyBundle:File:picture.html.twig')); }
テンプレート側で以下のように宣言
<td> {% block field %} {% if object.isImage %} <a href="{{ asset('uploads/assets') }}/{{object.name}}"> <img src="{{ asset('uploads/assets') }}/{{object.name}}" width="50px;" /> </a> {% else %} <a href="{{ asset('uploads/assets') }}/{{object.name}}">File</a> {% endif %} {% endblock %} </td>