Bukashk0zzz/LiipImagineSerializationBundle

"Notice: Array to string conversion" when trying to use an array of filters

Closed this issue · 3 comments

According to documentation:

filter can be array of filters in this case serialized field will be also array. For example if you add annotation @Bukashk0zzz\LiipImagineSerializableField(filter={"big", "small"})

However this seems to be broken or something. All I get is that error:

Notice: Array to string conversion

from class

Symfony\Component\Debug\Exception\ContextErrorException

If I put instead filter="small" it works and serves the image URL with the filter "small". But I can't find a way to serve all filters for the image (using VichUploader also) and I really need it for my API. Any other way or any clue to solve this?

Hi,

Example from project that now in production

@Bukashk0zzz\LiipImagineSerializableField(filter={"apartment_440", "apartment_1000"}, vichUploaderField="imageFile", virtualField="imageThumbs")

I think You need to add virtualField and all will work.

Thank you very much, works like a charm. Any chance to add it to documentation to make it crystal clear? So others don't make my mistake.
Documentation says:

Also there is another two not required options: vichUploaderField and virtualField

I guess it's the "not required" part that got me. Of course I knew that vichUploaderField was required but the virtualField could have a part where it says "it's required if you're using an array of filters" or something similar.
And/or adding it in the bottom example.

Anyways, great work with the bundle. And thanks again for your quick help.

BTW, nice avatar, The Chemical Brothers FTW haha.

@migmolrod thanks. I will update doc.