General idea would be to loop through all attachments to retrieve, modify and write back their meta.
Something like this (test thoroughly before using on anything important):
$posts = get_posts(array(
'post_type' => 'attachment',
'numberposts' => -1,
));
foreach( $posts as $post ) {
// retrieve data, unserialized automatically
$meta = get_post_meta($post->ID,'_wp_attachment_metadata', true);
// do stuff with $meta array
// write it back
update_post_meta($post->ID, '_wp_attachment_metadata', $meta);
}
Related Posts:
- How to delete outdated, wrongly sized images in _wp_attachment_metadata?
- How can I store an image in the database with Transients API?
- Regenerate missing _wp_attachment_metadata
- Is there a shortcut to change bulk BMP images to JPG images in a site?
- WP 3.4 has missing photo data
- Update image links in database
- Retrieving an alt tag from a custom field
- Get thumbnail url of custom meta image?
- Image thumbnails not available post migration, but still accessible via direct URL – DB issue
- Image upload appearing as broken images following server move
- Dynamic tagged image galleries
- I got an issue after i migrated a site
- Generate images to be associated for tag and category?
- Display an icon with get_post_meta?
- Upload media only to DB
- insert image alongwith with custom data via a frontend form
- Images are not showing after moving WordPress installation from server to localhost?
- Images not found after migrating WordPress website
- Image not showing using a custom function and get_post_meta
- Can I achieve this with WordPress?
- How to join Caption AND Description Meta Fields as one combined-caption in Image Block
- Save media files (images) to database instead of the filesystem
- How to Display Image Caption but Not Alt Text
- A query to substitute images paths in gutenberg (website migration)?
- JPG Image extension not inserting into Custom table of wp
- How to delete images from database with product
- get_post_meta returning broken path in image src
- Images not showing after moving site
- Adding Image Description below Images Inserted into Posts
- Why images are disappearing on WordPress web site?
- get_post_custom: get image URL instead of image ID
- Remove images (files) that were generated when using add_image_size()
- Displaying images from external RSS feeds?
- Why should I use “Organize my uploads into month- and year-based folders” option? (Cons/Pros)
- So much data in postmeta
- Which action hook can I use when a featured image has been selected
- Image resize with image url
- Migrating non-WordPress CMS to WordPress, lots of data to move — possible solutions?
- Preview Image Path in Admin Section
- The WordPress Gallery, Grabbing The Link and Images?
- Featured Images on Front Page
- How to get source of custom meta image?
- How to upload images from my directory into my wordpress?
- Ability to edit image via WYSIWYG
- Images are randomly deleted from server
- Rename media files generated during upload
- Featured image (responsive) above content is too small after update to WordPress 4.4
- Image popup in a lightbox / overlay from the backend 3.5 admin area (plugin)
- Auto resize images after adding a new size
- Upload .doc to blog
- media sideload image and Google Content
- Structure of postmeta meta_value for woocommerce product download
- Retrieving multiple values to the Post Meta (using an array)
- How can I insert an image map into a WordPress blog post?
- Add width & height attributes to Gutenberg’s image output?
- How to filter the image embed code based on link type
- Include image in excerpt
- Retain the original name of the image on resize
- Creating a post image to show in a gallery
- Don’t show images inserted into content
- Replace post/page titles with an image in WordPress
- What happened to the media manger?
- Howto use WP built in Thickbox for images?
- Remove Image Sizes in Media Settings Page
- image_resize() with blank space [closed]
- Re-ordering images in existing post in wordpress 3.6.1
- Removing Images from a WordPress Post
- Random Image Script Working but Want to Avoid Duplicates
- HTML Img with data:image src gets sanitized in admin?
- Can’t find image to remove
- How to add a custom class to all the images for a page only?
- How to link image in WordPress – Elementor when certain element does not offer that option?
- How can i place featured image after h2
- Custom image size not displaying with wp_get_attachment_image()
- Trouble with serialized metadata
- unsharp thumbnails after uploading image
- How to delete original image file after upload and resize
- Access html element in media modal with jQuery
- Jetpack Lazy load images fade in
- add alt text to images loaded from json with media_sideload_image
- Add Array record to Meta Post
- How to make image uploads default to full size?
- Image is missing on site homepage
- Changing current post image uls with a function
- Display images in template file
- How do i get value from wp_postmeta?
- How to display every pictures from all the posts on one page?
- How to add multiple images in a page
- See the all uploaded images of a user as an admin
- how to display all images from their siblings/ from same parent?
- Define Folder to save Images
- adding images to wordpress pagination?
- Custom filename when pasting an image from clipboard
- WordPress Bootstrap dynamic carousel showing images separately not as carousel
- How do you change all images dimensions to have the same size?
- Build Array from Input Fields question
- Media Library shows default image instead of image preview
- Profile Image displaying on Wrong side of WordPress Navigation Menu
- Uploading media to wordpress API with C# HttpClient
- How to add image alt attribute to the thumbnail code