I need to update “_wp_attachment_metadata” in wppostmeta tabele of image that was copy&paste to new localization.

Since WP documentation isn’t clear for me, I’d like to ask what should I input to $data argument?

wp_update_attachment_metadata( $post_id, $data );

$post_id is pretty clear, I can take it from database. What about $data?



I have tried this (98 is post_id/attachment-page id)

$data = wp_get_attachment_metadata( 98 ); 
wp_update_attachment_metadata( $post_id, $data );

but it doesn’t works I’ve also tried something like:

`while ($row = $post_id->fetch_assoc() and $media = $meta_value->fetch_assoc() ) { 
$row_id = $row['post_id']; 
$media_name = $media['meta_value']; 

update_post_meta( $row_id , '_wp_attachment_metadata' , $media_name );  

and it works I can see images/thumbnails, but when I try to edit image it says “No image data in file. Please send the image to the server again.”

Read more here: What kind of data should be in $data argument in the wp_update_attachment_metadata() function?


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: