WordPress.org

Ready to get started?Download WordPress

Forums

CSV Import Featured Image (2 posts)

  1. dompl
    Member
    Posted 2 years ago #

    I know this is was already on the forum about 8 months ago, but without solution

    I'm trying to import files to WP using CSV Importer. Everything goes well until I try to add featured image.

    Iv added my image via media library and trying to refer them in my CSV Files with image_thumb but with no effect

    Any help please?

  2. imperfectclark
    Member
    Posted 2 years ago #

    When featured images are added the following records go into the WP DB:

    wp_posts > 1 record

    • post_type = "attachment"
    • post_mime_type = "image/jpeg"
    • post_parent = (ID of post it's attached to)

    wp_postmeta > 2 records

    • _wp_attached_file = (relative path in /wp-content/uploads/, e.g. "2012/07/filename.jpg")
    • _wp_attachment_metadata = (really abstruse string containing a variety of size and other meta data)

    CSV Importer might be able to handle this. It will be able to import it as a post though not sure if it can handle the mime type field (try column header "csv_post_mime_type") - might not need it. As for the wp_postmeta key/value pairs, CSV Importer adds unfamiliar fields as records in the wp_postmeta table (with current post's ID), so including a column with heading "_wp_attached_file" will work, I think. The biggest problem is probably _wp_attachment_metadata field... you might be able to generate this value if you start have the filename and image width/height. But to give you an idea, here's a sample value from that field for an image added with default settings:

    a:6:{s:5:"width";s:3:"450";s:6:"height";s:3:"338";s:14:"hwstring_small";s:23:"height='96' width='128'";s:4:"file";s:14:"2012/06/mm.jpg";s:5:"sizes";a:2:{s:9:"thumbnail";a:3:{s:4:"file";s:14:"mm-150x150.jpg";s:5:"width";s:3:"150";s:6:"height";s:3:"150";}s:6:"medium";a:3:{s:4:"file";s:14:"mm-300x225.jpg";s:5:"width";s:3:"300";s:6:"height";s:3:"225";}}s:10:"image_meta";a:10:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";}}

    (the parts in bold are specific to my image)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags