Hi @christopheran,
I’m not sure, but it probably won’t do it automatically. But I think @simonkane did something similar, so maybe he could help. I created a hook function that happens right after wp_posts
table is upaded and before wp_postmeta
table is updated. So you can use it to customize what gets written to wp_postmeta
. If I remember correctly, that’s where the connection about features post image should be.
Here are some details about this custom hook:
/**
* Apply this filter to collect additional metadata and/or to run some additional actions,
* e.g. to "auto-connect" items to pages, posts, and WooCommerce products.
* Returning empty data will skip updating metadata (wp_update_attachment_metadata),
* so this filter can also be used to totally overwrite updating attachment metadata.
*
* This filter can be used in a number of different ways:
* 1.?to collect additional metadata,
* 2. to run some additional custom actions
* (e.g. to "auto-connect" items to pages, posts, and WooCommerce products),
* 3. to skip or completely overwrite updating the metadata (<code>wp_update_attachment_metadata</code> function),
* when this filter returns empty data (null).
*
* NOTE:
* Things could break if the filter doesn't return proper attach data
* and it hasn't created/updated the <code>wp_postmeta</code> table record (meta_key _wp_attachment_metadata).
*
* @since 1.2.5
*
* @param array $attach_data Data received from WP function: wp_generate_attachment_metadata
* @param int $attach_id
* @return array|null
*/
function my_custom_media_sync_before_update_metadata($attach_data, $attach_id)
{
// Custom logic here
return $attach_data;
}
add_filter('media_sync_filter_before_update_metadata', 'my_custom_media_sync_before_update_metadata', 10, 3);
I hope this helps.
Erol