Bukashk0zzz/LiipImagineSerializationBundle

wrong image url generated

Closed this issue · 2 comments

/**
 * @ORM\Entity
 * @ORM\Table(name="user")
 * @Vich\Uploadable
 * @Bukashk0zzz\LiipImagineSerializableClass
 */
class User extends BaseUser
{
    /**
     * @Assert\Image(minWidth=300, mimeTypes={"image/gif", "image/jpeg", "image/png"})
     * @Vich\UploadableField(mapping="member_image", fileNameProperty="photoName")
     */
    public $photo;

    /**
     * @ORM\Column(name="photo_name", nullable=true)
     * @Bukashk0zzz\LiipImagineSerializableField(filter={"member_small"}, virtualField="photoJs")
     */
    protected $photoName;

I am JMS-exposing fields using Yml file.

What gets serialized:

"photo": {
"member_small": http://app.local/app_dev.php/media/cache/resolve/member_small/579523e66cb25.png »
} ,

The correct url should be: http://app.local/app_dev.php/media/cache/resolve/member_small/media/members/579523e66cb25.png

Thanks

Hmm there still seems to be an issue:

http://app.local/app_dev.php/media/cache/resolve/member_small/579523e66cb25.png // wrong
http://app.local/app_dev.php/media/cache/resolve/member_small/media/members/579523e66cb25.png // should be like this

So it seems the media/members is missing in the url?

vich_uploader:
    db_driver: orm
    storage: gaufrette
    mappings:
        member_image:
            uri_prefix: /media/members
            upload_destination: member_image_fs
            delete_on_update: true
            delete_on_remove: true
            namer: vich_uploader.namer_uniqid

Seems like I forgot the vichUploaderField.

Annotation should be like this:

    /**
     * @ORM\Column(name="photo_name", nullable=true)
     * @Bukashk0zzz\LiipImagineSerializableField(filter={"member_small"}, virtualField="photoJs", vichUploaderField="photo")
     */
    protected $photoName;