Custom Fields
Support MB Custom Table Import images into custom table

  • Creator
  • #21079
    Resolved rebecmari


    I am working on re-creating a records database using MB Custom Table. The original database was from a custom site (not WordPress), and I have a CSV export of all the data from the original SQL database.

    I have created a custom post type for the records and am able to all save data from custom fields into the database. From the tests I have done, I am able to import most of the existing data into the site through the SQL database, so that part is working great. However, I am having trouble figuring out how to import the images affiliated with each record, since they are serialized in the database.

    In the CSV of data from the original site, the image file name is listed for each record. For example: '2429.JPG'. Originally, I was thinking I could add this data, upload the images to WordPress, and then build the url in the WordPress structure (i.e. '/wp-content/uploads/2020/07/' + '2429.JPG') to display the images. From a backend approach, I think I could make this work (even though it is a bit hackish), but going forward I was planning to have the images uploaded through the Meta Box image field, which serializes the I am back to square one. A couple of questions:

    1. Is there a way that I can import the images from the original database into the custom table (without manually uploading and entering all of them)?
    2. Thinking about longevity, if I ever need to export this database to be used outside of WordPress, would I be able to extract the file name out of the serialized image data? If so, how?

    I do primarily front-end dev, so I am not very knowledgable on a lot of this database work. Everything with your plugins so far has been straightforward to use for my skill level in helping to set this up. Appreciate any insight you can give to point me in the right direction!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
  • #21090
    Long Nguyen


    Let's dive a bit into the WordPress core and you will know how it stores the image information.

    • Each image after uploading to the Media Library is a post with the post type attachment. You will have the image ID and a link where the image stored
    • Meta Box image fields image, image_advanced, image_upload save the ID of the image (post ID attachment) into the database. It does the same as Featured Image of WP core, save the image ID in the table wp_postmeta with meta key _thumbnail_id.

    So in your case, I think you can do some steps:
    - Upload all images through Media Library.
    - Create a simple custom field like text to store the image URL.
    - Modify the CSV file, change the link of the image to the format
    - Import post meta through the CSV file with this plugin

    If you want to export the database to use outside of WordPress, you can use a third-party plugin to export the file. It will help you export the information you want to have in the file export.


    Hi Long,

    Thanks for the reply! This worked great. I combined your suggestion with the MetaBox File Input field (instead of text), so future images can also be selected from the Media library, and it will list their url in the database.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.