Custom Fields
Re-Envisioned
Support General Images attached to a custom post type

This topic contains 3 replies, has 2 voices, and was last updated by  Anh Tran 2 years, 2 months ago.

  • Creator
    Topic
  • #4659

    Martin
    Participant

    Hi Anh,
    I have question related to the attachments.

    In my case I have a website for used cars and when I built it, years ago, I used a plugin to let my client post from the front-end.

    This plugin is no longer working with the latest version of WordPress, I removed this old plugin and I installed the Meta Box plugin.

    This old plugin created some custom fields for brand, model, color and other stuff. With meta box I was able to retrieve that information. But I’m wasn’t able to get the images for each post.

    I was looking at this solution you provided here and using an image field but is not working.

    Here you can see a screenshot of the Meta Box working with the custom fields, another meta box with empty images, and the attachments of the post.

    What I’m trying to achieve is to put the images in any of the image uploaders available so that my client can later add more images or removed them.

    Thanks and let me know if you have any questions for me.

    Martin.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #4662

    Anh Tran
    Keymaster

    Hi Martin,

    That depends on how you store the images in the post meta. With Meta Box, image IDs are saved in the post meta (each image ID is saved a meta key). You can read more about that here.

    If the old plugin saves image IDs in the post meta in the same way as Meta Box, then Meta Box can show them without problem.

    But if it saves image URLs in the post meta, then you might want to use the field file_input instead (with clone parameter enabled if you have multiple images).

    And in the worst case, you can write a script to migrate the old data to the new format compatible with Meta Box.

    #4663

    Martin
    Participant

    Thanks for the reply, I was looking at the database and I guess that the images are stored the same way.

    Old images
    database table posmeta old image

    New image
    database table postmeta new image

    Do I need to use a callback like the one you posted here?
    http://pastebin.com/H7vqqx26

    Thanks!

    #4664

    Anh Tran
    Keymaster

    That seems the way WP stores attachment. I mean the way your old plugin stores images.

    The callback you mentioned in another topic is used to **display** the images only. It doesn’t help add/remove more images in the custom fields.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.