• Resolved norecipes

    (@norecipes)


    After switching themes recently I discovered that I a bunch of my older images are not showing up correctly as thumbnails or in the media browser. I’ve traced the problem to the fact that the problem images are missing both the “_wp_attachment_metadata” “_wp_attached_file” postmeta rows.

    The problem attachments do however have records in the posts table. Will this plugin generate “_wp_attachment_metadata” “_wp_attached_file” records for me? Thanks!

    http://ww.wp.xz.cn/plugins/force-regenerate-thumbnails/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter norecipes

    (@norecipes)

    Just incase someone has this same issue in the future, I answered my own question.

    The answer is no, Force Regenerate Thumbnails will not recreate both “_wp_attachment_metadata” “_wp_attached_file” postmeta rows for an image attachment because it relies on the get_attached_file function, which pulls the image path from _wp_attached_file.

    That said, I’ve found a workaround. I inserted the following code (courtesy of Sunriseweb on this thread: http://ww.wp.xz.cn/support/topic/plugin-auto-post-thumbnail-wordpress-34-previously-generated-thumbnails-missing-wont-generate-new-ones/page/3) to populate _wp_attached_file from the guid. The only thing is the guid has the full URI, so you’ll need to truncate everything up to the trailing slash on your domain. In my case my URI had 39 characters up to he image page “2008/09/sample-image.jpg”.

    Just insert the following code around line 446

    $fullsizepath = substr($image->guid,39,strlen($image->guid)); //change 39 to the number of characters in your URI up to the trailing slash
      update_attached_file( $image->ID, $fullsizepath );

    This goes just before the line

    $image_fullpath = get_attached_file($image->ID);

    To the plugin creator: Nice plugin! I especially like that it deletes old image sizes. I know this is a one-time issue for most people, but it would be nice if you could add the functionality to populate _wp_attached_file for an attached image if it doesn’t exist in future releases of the plugin.

    Plugin Contributor Pedro Elsner

    (@pedro-elsner)

    Thanks @norecipes
    ‘ll Implemented in version 2.0.2 =)

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

The topic ‘Does this plugin also regenerate postmeta’ is closed to new replies.