Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • yes.

    my generator code…

    [ Moderator note: please wrap code in backticks or use the code button. ]

    <?php /* meta generator */
    require ( ABSPATH . 'wp-admin/includes/image.php' );
    $args = array(
        'post_type' => 'attachment',
        'numberposts' => -1,
        'post_status' => null,
        'post_parent' => null, // any parent
        'post_mime_type' => 'image',
        );
    $attachments = get_posts($args);
    $auto_incr_meta = $wpdb->get_var( 'SELECT MAX(meta_id) FROM wp_postmeta' );
    $auto_incr_meta++;
    
    if ($attachments) {
    
        foreach ($attachments as $post) {
                setup_postdata($post);
    if(wp_get_attachment_metadata( $post->ID, false )){
    //echo '1';
    }else{
    //echo '2';
    $data = wp_generate_attachment_metadata( $post->ID, $post->guid );
    	$wpdb->insert(
    	'wp_postmeta',
    	array(
    		'meta_id' => $auto_incr_meta,
    		'post_id' => $post->ID,
    		'meta_key' => '_wp_attachment_metadata',
    		'meta_value' => '',
    	));
    
    wp_update_attachment_metadata( $post->ID, $data );
    $auto_incr_meta++;
    
    //echo $value;
    //break;
    }
        }
    }
    ?>

    Dont now how good this is but it worked for me 🙂 basicly it checks all attachment(image) posts and if they dont have meta it will generate it and then add it to the postmeta table.

    Had similar problem, in my case pictures where showing up 1px*1px (after 3.7 update), noticed that some images where missing attachment_meta. Generated that and now pictures are showing up fine.

Viewing 3 replies - 1 through 3 (of 3 total)