wpmetabox / meta-box

The best plugin for WordPress custom fields and custom meta boxes
https://metabox.io
1.19k stars 422 forks source link

Meta Box Custom table - Image field serialized with only one value #1609

Closed giuliodelmastro closed 1 month ago

giuliodelmastro commented 1 month ago

In my Meta Boxes I have a “thumbnail_id” field of type “image”. By saving the value in a custom table this is always serialized, despite the fact that it is not an array and the maximum image value is “1”.

Is there any way to solve this problem?

wgstjf commented 1 month ago

Have you tried the single_image field? That should save just the image id for you.

https://docs.metabox.io/fields/single-image/

Cheers, Will

rilwis commented 1 month ago

image field always save multiple values, despite limit is set to 1. If you want to use only 1 image, it's better to use single_image field as @wgstjf suggested.