Running the wp media regenerate command from WP-CLI with the --only-missing argument is quite fast (takes about 30 seconds for 4000 images) and rebuilds _wp_attachment_metadata correctly:
wp media regenerate --only-missing
Related Posts:
- Programmatically adding images to media library
- Uploaded images don’t show in Media Library if there are special characters in IPTC Keywords
- How can I hide media library images from general users?
- Get images attached to a specific page
- WordPress Attachments with old images
- How can I use an image from an external source without uploading it to the media library
- How to delete resized (cropped) image uploads and prevent future resizing?
- wp_get_attachment_image_src and server path
- How to find attachment by it’s name?
- Why is wp_get_attachment_image_src not working with my custom size (add_image_size)
- Theme Customiser Image Control
- Associate an existing image with a post
- How to rename an image attachment filename using php
- Programatically creating image attachments from local URLs and setting featured image
- How do i upload an image and return the image id?
- Get Attachment ID from URL [duplicate]
- How to remove title attribute from gallery links and images
- WordPress function: limit size, only jpg, jpeg, limit of uploaded files per account
- How to upload image without post ID using the new media uploader?
- Cannot access the thumbnails of attachment images… Cannot find the reason
- Applying class to links around self hosted images embedded to posts/pages
- Pulling Post Image Attachments in WordPress 3.9
- Import Images from one self-hosted WordPress install to another
- Link Featured Thumb to Attachment Page, If Possible
- How can I autopopulate titles in the media library?
- Image still linked as attachment to page even though it has been deleted
- How to change ID of an attachment in wp_posts and its related tables correctly?
- Why can I not view image attachment pages?
- Images are randomly deleted from server
- Add a new data attribute in tag
- Link to full size image or attachment page in photo theme
- HTTP Error when uploading files above 7mb unless using GD Image Editor
- add the post as canonical for attachment page wordpress
- Consolidating two websites into one, but migrated images not appearing in Image Library
- wordpress media library shows empty images
- Retrieving an alt tag from a custom field
- Add an attribute to attachments
- offload media to external services [closed]
- Pull images from the gallery
- How to upload images in a specific folder using API
- AJAX – save an $_FILES picture in media library
- Customizing the attachement page to show rest of all images in a gallery from post
- How to prevent WordPress scaling large images down
- Searching for any images in media library displays “no media found”
- How to get file URL from media library
- Change media URL (images)
- Add custom text in the media library image meta area
- Add attachment for all images in post
- get_post_meta not working on category.php
- Generate images to be associated for tag and category?
- Does wp_get_attachment_image_src also work with non-image files?
- Why does WP allow to view and media item as a page
- Images are not showing up in “Uploaded to this post”
- WordPress Creates Unused (Unregistered) Image Sizes
- Images don’t update after being edited
- Remove “%” from strings in serialized arrays in wp_postmeta
- Is there a way in WordPress to convert images to WebP without a plugin?
- Some Images Disappeared from Media Library?
- are unattached media files a problem?
- Large image not showing dimensions in Media Library
- What is the best way to associate multiple images to one page?
- Function to grab specific image IDs from media library.
- How to get the cropped image from media library?
- Random Characters in the end of every image url in post
- Fetching uploaded images using Link URL
- How to replace post image url before posting using api?
- How to get post id of first child of the same post type?
- Can i have 2 separate Galleries on 2 separate pages each go to a DIFFERENT Attachment.php file?
- Attachments without images
- How can i sorting and display image order by siz in media library?
- WordPress append -1 to the image name
- Auto delete content in specific folder inside media library
- Media Library Cleanup A Thought Exercise
- wp_insert_attachment() dupplicate attachment posts
- How to echo images Urls from a wordpress post, that are relally in the post
- How to Display Image Caption but Not Alt Text
- Could creation of various image sizes cause slow form submission response?
- imported post image as normal image instead encoded image
- Allow users to upload attachments to certain posts
- WordPress Link To Image Missing Dropdown
- wp_get_attachment_image_src calling wrong location
- How can I add an “Attach image to this post/page” link on the Add Media lightbox?
- Troubles with code for upload a image
- get_post_meta returning broken path in image src
- Adding Image Description below Images Inserted into Posts
- Create a custom attachment thumbnail for quick page load
- Change the image for a certain URL
- Assign one featured image to multiple posts?
- Some images don’t get linked when setting link-to to media-image
- How can I hide previous_image_link() on first attachment page?
- How do I embed an image at actual size?
- Image media upload problem in page editing modus?
- How to access & display images from a post without textual content ( and vice versa) according to best wordpress practices
- My image rotate 90 degree
- get_post_custom: get image URL instead of image ID
- How can we see which posts don’t have a featured image or it doesn’t exist anymore?
- Why some images are not allowed to be edited only for thumbnails?
- What does WordPress media uploader do to image files on upload?
- How to get WordPress to resize images for srcset?
- Define how an attached image is rendered