How to list thumbnail of Image in sonata admin bundle

1,505 views
Skip to first unread message

Dev swaam

unread,
Jun 23, 2014, 7:58:24 AM6/23/14
to sonata...@googlegroups.com

I want to get my image thumbnail listed in list area, i don't know how to do that, can any one please help me. I Got my caption in back end. I am using Sonata adim bundle and following its official document.

here is my imageAdmin.php



namespace swaam\ImageUploaderBundle\Admin;


use Sonata\AdminBundle\Admin\Admin;

use Sonata\AdminBundle\Datagrid\ListMapper;

use Sonata\AdminBundle\Datagrid\DatagridMapper;

use Sonata\AdminBundle\Form\FormMapper;


class ImageAdmin extends Admin

{


// Fields to be shown on create/edit forms

    protected function configureFormFields(FormMapper $formMapper)

    {

        $formMapper

            ->add('caption', 'ckeditor', array('label' => 'Ca   ption'))

//            ->add('file', 'entity', array('class' => 'swaam\ImageUploaderBundle\Entity\image'))

            ->add('file', 'file', array('data_class' => 'Symfony\Component\HttpFoundation\File\File'

            ,'property_path' => 'file'

            ))


            ->end(); //if no type is specified, SonataAdminBundle tries to guess it

        ;

    }


// Fields to be shown on filter forms

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)

    {

        $datagridMapper

            ->add('caption')

            ->add('thumbpath')

        ;

    }


// Fields to be shown on lists

    protected function configureListFields(ListMapper $listMapper)

    {

        $listMapper

            ->addIdentifier('caption')

//            ->add('thumbpath')

              ->add('thumbpath')

        ;

    }

}

Cassiano Tartari

unread,
Jun 23, 2014, 9:45:02 AM6/23/14
to sonata-users

On Mon, Jun 23, 2014 at 8:58 AM, Dev swaam <devs...@gmail.com> wrote:
thumbpath



Cassiano Valle Tartari
MSc. Computer Engineer

Tel: +55.48.84474818
Email: fal...@cassianotartari.eng.br
Site: http://www.cassianotartari.eng.br

QR Code

Dev swaam

unread,
Jun 23, 2014, 9:47:11 AM6/23/14
to sonata...@googlegroups.com
ahh... it is not even bringing the path... 


--
You received this message because you are subscribed to a topic in the Google Groups "sonata-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonata-users/S1D2VZoRlvE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonata-users...@googlegroups.com.
To post to this group, send email to sonata...@googlegroups.com.
Visit this group at http://groups.google.com/group/sonata-users.
For more options, visit https://groups.google.com/d/optout.

Dev swaam

unread,
Jun 23, 2014, 9:53:32 AM6/23/14
to sonata...@googlegroups.com
Here is my relevant function

protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('caption')
            ->add('thumbpath', NULL , array('template' => 'swwamImageUploaderBundle:Admin:list_image.html.twig'))
        ;
    }

and here is my twig.html

{% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %}

{% block field%}

    <div>
      {#<img src="{{ image.webPath | imagine_filter('gallery_element_admin') }}" />#}
        <img src="{{ image.thumbpath }}">
    </div>
{% endblock %}


and i m bit confused, not sure if i am doing this in right way or not ? Guide me please if u got it !


On Mon, Jun 23, 2014 at 6:44 AM, Cassiano Tartari <cassian...@gmail.com> wrote:

--
Reply all
Reply to author
Forward
0 new messages