2

I'm having an issue while upgrading WP from 3.2.1 to 3.5.2, where one section's Featured images have all been deleted. When I visit that section's edit post pages, the featured image thumbnails that were once there are no longer there. Is this a database issue? I just dumped/restored my database an hour ago. I'm wondering if the WP database upgrade deleted my data.

Which table do the featured images data go under? I'm wondering if I could just dump/restore that table again, but I don't know which one it is. My images are still there, but the links to them don't seem to exist in the database.

2 Answers 2

6

The featured image itself-- the actual .jpg, or .png, most likely-- is saved to wp-content/uploads with primary image data saved to $wpdb->posts as an attachment post type. Additional relevant data for the image is saved in $wpdb->postmeta.

What makes an image "featured" or not is an entry in $wpdb->postmeta under the key _thumbnail_id and a post_id field matching the post ID of the post for which the image is a "feature"-- aka thumbnail.

It is hard to say where things have gone wrong. It could be any three of those components.

0

The featured image ID is stored in wp_postmeta with a meta_key called _thumbnail_id. Example:

╔═════════╦═════════╦═══════════════╦═══════════╗   
║ meta_id ║ post_id ║ meta_key      ║ meta_value║         
╠═════════╬═════════╬═══════════════╬═══════════╣   
║ 200     ║ 4       ║ _thumbnail_id ║ 48        ║   
╚═════════╩═════════╩═══════════════╩═══════════╝  

The actual thumbnail link is then contained in wp_posts with a post_type of attachment. Example:

╔════╦════════════╦═════════════════════════════════════════════════════╗
║ ID ║ post_type  ║ guid                                                ║
╠════╬════════════╬═════════════════════════════════════════════════════╣
║ 48 ║ attachment ║ http://example.com/wp-content/uploads/yourimage.png ║
╚════╩════════════╩═════════════════════════════════════════════════════╝

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.