Once you have the attachment ID you can add alt text by setting the _wp_attachment_image_alt
post meta for the attachment:
update_post_meta( $attachment_id, '_wp_attachment_image_alt', 'Alt text here' );
To get the attachment ID from media_sideload_image()
you can set the 4th argument to 'id'
:
$attachment_id = media_sideload_image( $file, $post_id, $desc, 'id' );
if ( ! is_wp_error( $attachment_id ) ) {
update_post_meta( $attachment_id, '_wp_attachment_image_alt', 'Alt text here' );
}
Related Posts:
- Separate Media Library for each user
- Maintaining image color and quality when uploading using custom sizes
- Bulk edit wordpress images alt and title attributes
- Upload Image Not accessible
- Which are precisely the predefined image sizes?
- Separate attachment images from post loop
- Caption in Page adding unwanted 10px to width
- Adjust image caption within visal editor
- Change Image URL to a CDN
- Why can’t I edit certain images from the WordPress Media library?
- How to add a media with PHP
- Responsive Images – Add srcset attributes to custom Images Function
- Get original image from thumbnail URL
- Loss of sharpness in jpg imported as header in twentyeleven
- WordPress url image redirect to the homepage
- Bulk image rotation
- Can I the caption shortcode to set caption to a data attribute, and with the image’s alignment intact?
- Is there a way to delete images from WordPress media library programmatically?
- get the image of the post
- Update image links in database
- Special purpose photos with each post
- ACF Image ID, echo the alt tag
- WordPress – different icon image depends of comment number
- Change WordPress Media Manager
- How to stop images from being wrapped in tags?
- Pull Random Attachments With Pagination
- Upload media files to Amazon S3
- Out of memory error reporting
- How to get default image sizes attribute
- Remove the inline styling added in wp_get_attachment_image()
- Image not shown in the theme as it’s showing in HTML template [closed]
- Broken image links even though links are correct and images exist
- Broken Images until Page Refresh
- Show image crop window on image upload
- Get image from parent category
- Images attached to posts from library link to 404 error page
- Images not displayed when moving site to local
- Caption and title in img alt tag are the same?
- Uploaded images not displaying in network site
- fetch images and videos
- Specific image size is being generated without being registered
- Should I not compress my jpeg files before uploading to avoid double compression?
- Generating a certain sized thumbnail on the fly?
- How to display title of attached image in post?
- Getting thumbnail of uploaded image
- Display image for first sticky post only
- Get all image IDs from the Media Library
- Link listings with image
- Allow users to contribute images to a post
- Can’t add image to site via php
- After Migration, images show up on a preview of the page but not the actual page [closed]
- Is it possible to enable the ‘Link To’ field under ‘Attachment Display Settings’ for a Featured Image?
- How to apply image alt descriptions from media library?
- Save Image in wp_options-Table
- Can I register a new thumbnail size and have it be an option in “Add Media”?
- Specify automatically the height and weight of the images
- Image upload error?
- Is it possible to get feature image url (full-size) from an image url of smaller size?
- How to crop images in a certain size only for a certain page?
- How to pass on a value as parameter via url to another page
- Image not showing using a custom function and get_post_meta
- Random home page background images with caption text
- How to add “alt” attribute for image during upload at WP front-end?
- Get Original Dimension Featured Image on the homepage
- WordPress keeps resizing my 947×947 image down to 500×500 (full-size option)
- Excluding post thumbnail from the attachment.php when using wordpress gallery
- Featured Image Thumbnail size on Twenty Ten Archive Page
- Using different size thumbnails on different parts of my site… with functions.php?
- attach several images to post + gallery
- Widget Style – Icon Type
- WordPress Problems
- Pictures randomly replaced by blue question mark
- WordPress PHP custom function is causing 500 Internal Server Error Connection Timeout
- Post-processing of the image failed
- Get post thumbnail in specific size
- How to find the largest images in wordpress post
- New portfolio items appearing smaller on the grid
- Image automatically resized
- Theme page headers and rotator images not assigned after website migration
- WAMP install acts different than live install when uploading images
- Images Wont Display After Importing From Old WordPress
- Image thumbnail on single product issue | WooCommerce
- How can I hook and edit on the fly an image uploaded
- Anomaly with response coming from XML RPC Api get Post (integer out of range)
- Make all images displayed in single.php a certain size
- Create a custom attachment thumbnail for quick page load
- Change the image for a certain URL
- I am trying to get metabox image with custom size
- Removing image dimensions from `the_content`
- Is there a different way to grab a thumbnail image than this?
- Multiple gallery thumnbnails on one page
- Change image link in excerpt to point to post
- Putting the title attribute in image tag — Snapshot Theme from Woothemes
- Post migration – images do not display
- Change the avatar ratio?
- wp_handle_upload Image sizes
- Display Images from Array with wp_get_attachment_image() [closed]
- I am having trouble displaying an image at the top of a widget area [closed]
- Can’t upload svg files in WordPress
- Images uploaded in customized gallery do not link to media