LiipImagineBundle Изображение не появляется после фильтрации

Я использую VichUploadBundle для загрузки изображений в свою базу данных и хочу, чтобы миниатюры изображений отображались на веб-сайте с помощью LiipImage.

Это мой config.yml с настроенными файлами

 //.....
vich_uploader:
    db_driver: orm
    twig: true
    mappings:
            product_image:
                uri_prefix:         /images/products
                upload_destination: '%kernel.root_dir%/../web/images/products'

                inject_on_load:     false
                delete_on_update:   true
                delete_on_remove:   true

liip_imagine:

    # configure resolvers
    resolvers:

        # setup the default resolver
        default:

            # use the default web path
            web_path: ~

    # your filter sets are defined here
    filter_sets:

        # use the default cache configuration
        cache: ~
        # the name of the "filter set"
        my_thumb:

            # adjust the image quality to 75%
            quality: 75

            # list of transformations to apply (the "filters")
            filters:

                # create a thumbnail: set size to 120x90 and use the "outbound" mode
                # to crop the image when the size ratio of the input differs
                thumbnail: { size: [120, 90], mode: outbound }

                # create a 2px black border: center the thumbnail on a black background
                # 4px larger to create a 2px border around the final image
                background: { size: [124, 98], position: center, color: '#000000' }

Большая часть кода для liip скопирована прямо из документации для тестирования.

Это мой routing.yml

app:
    resource: "@AppBundle/Controller/"
    type:     annotation

_liip_imagine:
    resource: "@LiipImagineBundle/Resources/config/routing.xml

Наконец, у меня есть объект изображения, который я хочу загрузить. Это также код, скопированный из официальной документации Vich.

<?php
namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;

/**
 * @ORM\Entity
 * @Vich\Uploadable
 */
class Image
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    // ..... other fields

    /**
     * NOTE: This is not a mapped field of entity metadata, just a simple property.
     *
     * @Vich\UploadableField(mapping="product_image", fileNameProperty="imageName")
     *
     * @var File
     */
    protected $imageFile;

    /**
     * @ORM\Column(type="string", length=255)
     *
     * @var string
     */
    protected $imageName;

    /**
     * @ORM\Column(type="string", length=100)
     *
     * @var string
     */
    protected $imageTitle = null;

    /**
     * @ORM\Column(type="string", length=100)
     *
     * @var string
     */
    protected $imageAuthor = null;

    /**
     * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
     * of 'UploadedFile' is injected into this setter to trigger the  update. If this
     * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
     * must be able to accept an instance of 'File' as the bundle will inject one here
     * during Doctrine hydration.
     *
     * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
     *
     * @return Product
     */
    public function setImageFile(File $image = null)
    {
        $this->imageFile = $image;

        if ($image) {
            // It is required that at least one field changes if you are using doctrine
            // otherwise the event listeners won't be called and the file is lost
            $this->updatedAt = new \DateTimeImmutable();
        }

        return $this;
    }

    /**
     * @return File|null
     */
    public function getImageFile()
    {
        return $this->imageFile;
    }

    /**
     * @param string $imageName
     *
     * @return Product
     */
    public function setImageName($imageName)
    {
        $this->imageName = $imageName;

        return $this;
    }

    /**
     * @return string|null
     */
    public function getImageName()
    {
        return $this->imageName;
    }

    /**
     * @ORM\Column(type="datetime")
     *
     * @var \DateTime
     */
    protected $updatedAt;

    /**
     * @return null
     */
    public function getImageTitle()
    {
        return $this->imageTitle;
    }

    /**
     * @param null $imageTitle
     */
    public function setImageTitle($imageTitle)
    {
        $this->imageTitle = $imageTitle;
    }

    /**
     * @return null
     */
    public function getImageAuthor()
    {
        return $this->imageAuthor;
    }

    /**
     * @param null $imageAuthor
     */
    public function setImageAuthor($imageAuthor)
    {
        $this->imageAuthor = $imageAuthor;
    }
}

В моем контроллере таблица изображений помещена в массив с помощью $em

$em = $this->getDoctrine()->getManager();
$list = $em->getRepository(Image::class)->findAll();

Которые я позже поместил в представление и (хотел бы) распечатать их так:

{% for l in list %}
        <tr>
            <td>
                <img src="{{ asset('/images/products/'~l.imageName) | imagine_filter('my_thumb') }}" alt="{{ l.imageName }}">

            </td>
            <td>{{ l.imageTitle }}</td>
            <td>{{ l.imageAuthor }}</td>
        </tr>
    {% endfor %}

К сожалению, вывод выглядит следующим образом: Вывод веб-сайта


Теперь дорога в порядке. Изображение хорошо работает без imagine_filter(). Тот же эффект будет иметь место при использовании активов Vich.

При проверке путь, по которому связано изображение, выглядит следующим образом:

http://localhost:8000/media/cache/resolve/my_thumb/images/products/hqdefault.jpg

Путь к изображениям

Интернет/изображения/продукты


Может есть кто знает в чем может быть дело?

Или предоставить альтернативный пакет для создания миниатюр изображений

Вся помощь была бы потрясающей


person aln447    schedule 16.02.2017    source источник
comment
Проверьте логи, попробуйте создать фодер /web/media с правами владельца веб-сервера (или 777).   -  person malcolm    schedule 17.02.2017


Ответы (1)


ИСПРАВЛЕНО: включение GD и имен файлов в php.ini и переустановка apache с последующей очисткой кэша все исправили.

person aln447    schedule 16.02.2017