Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

What are the meta fields for an attachment?

You can easily inspect all the metadata for any post like so:

// 123 is the (attachment) post ID
var_dump( get_post_meta( 123 ) );

And in a default WordPress setup with no plugins or theme which add custom metadata to the image attachment post, the metadata you’d get are:

  • _wp_attached_file — string, the image file (path and name) for the attachment post

  • _wp_attachment_metadata — array (serialized), the sizes for the image like ‘thumbnail’ (including original size), and metadata from EXIF/IPTC info.

  • _wp_attachment_image_alt — string, the image’s alternative text

As for the other details like the image title, they are in the post data (in the posts database table), so you can for example use wp_update_post() to update these details:

  • post_title — image title

  • post_excerpt — image caption

  • post_content — image description

Related Posts:

  1. remove links from images using functions.php
  2. How to add classes to images based on their categories?
  3. Auto delete WordPress images/thumbnails (all sizes) and featured after X days/hours, or similar?
  4. How to add a rel attribute to images that contains their categories?
  5. Best way to programatically add “rel” attributes to page and post images
  6. Can’t check if a post has thumbnail adding filter to get_post_metadata()
  7. Image rotation fails to regenerate custom sized thumbnail
  8. Display images that are not in the content
  9. How to hide image-url if no attachment?
  10. Different image using srcset function
  11. Auto delete content in specific folder inside media library
  12. How to update an image attachment’s alt text from a custom field when saving a post?
  13. blank page with wp_get_attachment
  14. Open image size links in a page instead of direct image link
  15. Missing feature image link function
  16. Add image size if page template
  17. Set JPEG compression for specific custom image sizes
  18. Issue with wp_get_attachment_image() and SVG file type
  19. How to change the markup WordPress inserts for post images
  20. How to add a class to the attachment images
  21. Programmatically Set First Image as Featured
  22. Removing default image size list in Media Box
  23. How to use get_template_directory_uri() to load an image that is in a sub-folder of my theme?
  24. WP 4.4. responsive loads normal image after loading the responsive image
  25. How to create thumbnails for PDF uploads?
  26. How to reduce original image quality on upload?
  27. Add options to featured image
  28. Is it possible to maintain image aspect ratio when scaling images?
  29. Set image size on media and text block with a function
  30. Generating Responsive Background Image Sizes in PHP
  31. Change meta tags programatically
  32. How to get meta value in wp_attachment_metadata
  33. Why are image thumbnails cropped proportionally (not per dimensions)?
  34. Use a function to update post meta based on other post meta
  35. Create thumbnail on PDF upload with Gravity Forms
  36. Gallery images titles – get from post
  37. Display info from custom fields in all images’ HTML
  38. Remove images from get_the_excerpt
  39. update_post_meta for custom field not working upon form submission
  40. Use Exact Image Size using add_image_size
  41. copy attachments to another post type and change attachment url
  42. Assign category using custom field?
  43. Why are image thumbnails cropped proportionally (not per dimensions)?
  44. Display height and width properties with the_post_thumbnail() or related function
  45. Insert width & height attributes to all images displayed on each page
  46. Converting a simple plugin to be placed inside of functions.php
  47. Regenerate missing _wp_attachment_metadata
  48. Custom image size in Media Dropdown
  49. Convert User ID’s to User Names in a single.php file
  50. Removing the first image in content
  51. Function to auto-set a featured image that is already in use
  52. Actions according to image type and size
  53. What is the “icon” parameter in wp_get_attachment_image_src used for?
  54. How to change ID of an attachment in wp_posts and its related tables correctly?
  55. Woocommerce Storefront WordPress Ignore Media Gallery Images and use External 3rd Party Host
  56. Overwrite Parent Theme add_image_size in Child Theme
  57. Images uploaded using media uploader are appearing upside down
  58. Find first image on paginated post for Pinterest
  59. How to add css class to image attached in all the posts?
  60. Add custom image size not working
  61. Count total number of images in post and echo results as number
  62. How can you limit srcset on a single type of page?
  63. how to add an image to the footer?
  64. How do I permanently Disable Attachment Post URL
  65. wp_get_attachment_image function size argument not working if I also add a custom class
  66. Automatically wrap multiple images in div
  67. Understanding and altering the structure of posted images
  68. Overwriting Parent Theme’s Image Sizes
  69. Load post attached images on a single page site with fancybox
  70. Publish/Update post is changing image links from file url to post url
  71. Featured Image Thumbnail Creation
  72. Twentyten Child Theme: header images display messed up in admin panel
  73. Move Post to different category if post_meta field is 0 or is 2 days old?
  74. Disable auto-resizing of uploaded images, but only for certain filename
  75. Can you put a condition on add_image_size() depending on the width of the uploaded image?
  76. What WordPress function to use to get meta value by using meta keys?
  77. show first 3 thumbnails of posts in different sizes [closed]
  78. Remove after images
  79. Getting custom image size URL in functions
  80. Set spesific size of featured images
  81. Default Custom Field Value Automatically Update
  82. Can’t generate thumbnail images
  83. media resize/crop possibilities?
  84. Post meta not updating
  85. Function to update post_meta based on existing post_meta
  86. get_post_meta not working on category.php
  87. Can’t filter wp_get_attachment_link
  88. Get ID of first image attached to a post
  89. How to stop wordpress from injecting hard-coded style into image attachments with captions
  90. Exclude from the query posts with meta_key and meta_value
  91. Control the srcset much more (not all sizes in it each time)
  92. Way to store featured image width and height in two separate variables?
  93. Prevent custom field from being updated after first publish
  94. srcset and custom field get_post_meta and wp_get_attachment_url
  95. Limit dimensions of “Full” size images
  96. Get array of metakey in all posts
  97. Visual Composer creating own shortcodes with vc_map() to return simple Image
  98. User function to return multiple get_post_meta()
  99. attachment page template? only show attachments for current post?
  100. How to get an attachment id from a filename
Categories functions Tags attachments, functions, images, post-meta
Is there a way to add custom endpoint to specific page only
WP_Query to output chosen term and posts with no term assigned

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress