WordPress stores image (attachment) data as follows:
- Description:
post_content
field - Caption:
post_excerpt
field - Alt:
_wp_attachment_image_alt
meta value
And in code, that translates to:
// Description
echo $post->post_content; // Raw
the_content();
// Caption (description as fallback)
the_excerpt();
// Caption (explicitly)
echo $post->post_excerpt; // Raw
if ( has_excerpt() ) {
the_excerpt();
}
// Alt
echo get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
Related Posts:
- Shortcode function doesnt work without caption
- Adding caption to all images inside an article
- How to add a class to the attachment images
- Change the filename format of saved featured images
- How to register images uploaded via FTP in media library?
- Using file_exists to check file in Uploads
- Rename image uploads replacing “width” and “height” in filename with “medium”, “large”, “small”
- Rename image uploads with width in filename
- Debugging upload problem: What part of WP does actual image-resizing?
- Add custom image sizes to media uploader
- Conditional Statement – check if post has an attachment image
- How to upload imagick resource to media in wordpress
- Use Filename for Alt and Title Tags
- Change Width of Featured Image Thumbnail on Add/Edit Post Page
- Use Timber/Twig to pull an image by image ID [closed]
- Adding graphics to 404.php page
- How do I get images (with a thumbnail preview) to show in search results?
- Add custom HTML to posts page
- Strip Image Classes from HTML Output
- Customized title tag for each page in pagination?
- Adding a querystring to an image URL when clicking ‘insert into post’?
- Assign a picture URL to a page via PHP
- Change logo based on incoming domain
- How to scale image with equal width and height without distortion?
- Theme currently showing thumbnails, how to show full size?
- Validate Uploaded Image using WordPress’ Built-in Functions?
- How do themes render caption texts in extended markup (e.g. “wp-caption” paragraphs)
- Get most recent media upload
- Convert all images to PNG on file upload
- Escape post image attachments added to template
- Auto crop images in WordPress
- Display post image with fancybox
- Get different images for mobile and desktop with php, advanced custom fields without using js and ajax
- HTML tags in bloginfo description
- add_image_size for header_image
- Get image’s size name from it’s dimension
- Cannot display or echo alt text on featured image
- Recent posts with featured image or fallback image with permalink
- Set the background to a default image if there isn’t a specified “featured image”
- Mass update excerpt
- How to control WordPress image metadata (using Imagick)?
- How to get next image with this code from same post?
- Can’t upload image using media_sideload_image
- How to use thumbnail size of image if I’m only using src to get image
- get_children displaying images removed from the page
- Enable custom logo upload if logo is not in header
- How can I add an area/option for a custom page description?
- Scrape external webpage for first image and add it to new post
- “imagejpeg” function is not working in wordpress
- Display image from an external rss feed on wordpress without plugins
- Download images from media library to computer in BULK?
- Three Questions with Twenty Eleven theme
- Which function crops images in wordpress?
- Division by zero error in image.php
- Resize image to specific dimension (X to Y ratio)
- How can I automatically resize up images to fit into all of my registered image sizes
- Upload non-featured image to image field
- I’m unable to call img path using single quotes in an array?
- Get the id of all images in a post
- Else/If Statement to Display Photo Descriptions
- Controlling image output size ACF repeater [closed]
- WordPress İmages Upload & Delete Error
- Generate responsive post thumbnails of same size
- Attaching images to posts manually (i.e. with custom code, without the use of an API)
- How to internationalize header image?
- Add Custom Category Description When Empty
- WordPress api post image raw data without being blank in media library
- WordPress loading all local images from specific directory?
- Not able to remove caption shortcode from the content
- not outputting medium size image URL
- How to use data URL in WordPress?
- Resize post thumbnail
- Where Do Image Dimensions Get Added To A Filename?
- I have a background-image in css file but don’t show in site.how to fix this prblm. i sent screenshot. thx
- How do I stop an Image Address from loading in the Browser?
- How to add a PHP scripts into WordPress
- Featured images duplicating and replacing next image
- I can’t load my images from a js file using wp_localize_script
- How to create an unordered list of images separate from the content
- View tag description on page
- what’s the syntax for if the image exists get the image?
- How do I get the featured post to share on Social Media and show on Individual Post pages?
- How to change this internal image link parameter using PHP?
- Extend the WP_Customize_Image_Control class to change its non-frame $button_labels
- How to resize an image server-side before upload?
- Snapshot Theme from WooThemes — empty ‘alt’ attribute
- Setting post thumbnail sizes in template file and functions.php
- Determine if only one image attached to a post/page
- Crop images in both sides on wordpress [duplicate]
- upload images on front by user using form
- PHP-Code inside Href-Tag
- HTML in PHP problem [closed]
- Adding slides to an existing carousel manually
- An automatic way to crop images of different sizes
- Remove default Image Sizes
- WooCommerce: write featured image dimensions to custom fields in product’
- Generate and upload screenshot as featured image for user-submitted post
- How Create Automatically Image jpg.webp from image .jpg without delete or change original images upload
- Using Featured Image as Hero Background in Word Press
- How can add alt tag in following code. Image are showing dynamic in wordpress