• Regenerate thumbnails was working perfectly for me, but without any reason that I can find, it just stopped. I’ve added no more plugins, functions, etc., just stopped one night and started the next. I’ve been doing it in batches through the dropdown menu in the Media section

    The error I keep getting now is:

    (ID 1493) failed to resize. The error message was: The originally uploaded image file cannot be found at...

    Any idea what’s going on?

Viewing 3 replies - 16 through 18 (of 18 total)
  • I discovered why the icons aren’t showing up. It appears that previous versions of WP ignored the _wp_attached_file meta key, where the newest version requires it for looking up the attachment data. The attachments that weren’t displaying were missing this key.

    Below is PHP code for descending through the post database, verifying the presence of this key (and file) and updating accordingly. I’ll leave it to you to add it to your theme (I added it to a submenu for database tools). After processing, it will display the number of updates, skipped posts and errors.

    // descend through the database
    $updated = 0;
    $skipped = 0;
    $error = 0;
    $upload_dir = wp_upload_dir();
    
    $sql = sprintf("select * from %s where post_type = 'attachment'", $wpdb->posts);
    $all_attachments = $wpdb->get_results($sql);
    
    foreach ($all_attachments as $attachment) {
    	// get the meta value
    	$meta = get_post_meta($attachment->ID, "_wp_attachment_metadata", true);
    	$file = $meta['file'];
    
    	// verify that the file exists
    	$file_path = $upload_dir['basedir'] . '/' . $file;
    	if (!file_exists($file_path)) {
    		$error++;
    	}
    	else {
    		// add the meta value, which returns false if it already exists
    		$adding_meta = add_post_meta($attachment->ID, '_wp_attached_file', $file, true);
    		if ($adding_meta)
    			$updated++;
    		else
    			$skipped++;
    	}
    }
    echo '<div id="message" class="updated"><p>' . sprintf("%d attachments were updated, %d were skipped and %d had errors.", $updated, $skipped, $error) . '</p></div>';

    Thanks wesg this is exactly the answer I was looking for, could you explain how to add it to a theme?

    Hey guys, having the same problem with this plugin…

    Tried the code from wesg, this is what I get:

    0 attachments were updated, 67 were skipped and 1 had errors.

    Any other ideas?

    EDIT: a solution can be found here (last post).

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘[Plugin: Regenerate Thumbnails] Stopped working, error msg’ is closed to new replies.