Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8871575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:01:18+00:00 2026-06-14T18:01:18+00:00

I am trying to modify the SonataAdmin templates. I have an Image entity that

  • 0

I am trying to modify the SonataAdmin templates. I have an Image entity that has a path property. I created an ImageAdmin class and this is integrated into sonataAdmin. I would like to modify the admin-list-view to wrap the path in an img tag so that the image is actually displayed. Does anyone know how I can do this?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:01:19+00:00Added an answer on June 14, 2026 at 6:01 pm

    There are 2 ways to use your own templates.

    In the config file:

    sonata_doctrine_orm_admin:
        entity_manager: 
    
        templates:
            form:
                - SonataDoctrineORMAdminBundle:Form:form_admin_fields.html.twig
            filter:
                - SonataDoctrineORMAdminBundle:Form:filter_admin_fields.html.twig
            types:
                list:
                   ...
    
                show:
                    ...
                    image: YourBundle:YourFolder:yourtemplate.html.twig
    

    and in the field definition file:

    <?php
                namespace ...;
    
                use Sonata\AdminBundle\Admin\Admin;
                use Sonata\AdminBundle\Form\FormMapper;
                use Sonata\AdminBundle\Datagrid\DatagridMapper;
                use Sonata\AdminBundle\Datagrid\ListMapper;
                use Sonata\AdminBundle\Show\ShowMapper;
    
                class ImageAdmin extends Admin
                {
                    protected function configureShowField(ShowMapper $showMapper)
                    {
                        $showMapper
                            ...
                            ->add('image', 'image')
                            ...
                        ;
                    }
                }
            ?>
    

    OR the 2nd way:

        <?php
            namespace ...;
    
            use Sonata\AdminBundle\Admin\Admin;
            use Sonata\AdminBundle\Form\FormMapper;
            use Sonata\AdminBundle\Datagrid\DatagridMapper;
            use Sonata\AdminBundle\Datagrid\ListMapper;
            use Sonata\AdminBundle\Show\ShowMapper;
    
            class ImageAdmin extends Admin
            {
                protected function configureShowField(ShowMapper $showMapper)
                {
                    $showMapper
                        ...
                        ->add('image', 'string', array('template' => 'YourBundle:YourFolder:yourtemplate.html.twig'))
                        ...
                    ;
                }
            }
        ?>
    

    And then copy the code below to your template:

    {% extends 'SonataAdminBundle:CRUD:base_show_field.html.twig' %}
    
    
    {% block field %}
        <img src="{{ asset('uploads/media/') }}{{ value|nl2br }}"/>
    {% endblock %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to modify (extend) the FileInputStream class so that I can open an
I am trying to modify a registry key that I have been told controls
I'm trying to modify some exports. I understand that this code doesn't work because
Im trying to modify the class below so that the scrolling text appears behind
I am trying to modify the tutorial Ray Wenderlich has created at: http://www.raywenderlich.com/1888/how-to-create-a-simple-iphone-app-tutorial-part-33 So
I am trying to modify a VS add-in, this addin has multiple projects. The
I am trying to modify the android lvl library and as part of this
I am trying to modify the script below to click a button that looks
I am trying to modify Apple's PhotoScroller example and I encountered a problem that
I am trying to modify a script that was developed to import article records

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.