Try adding these codes to your theme’s function.php
file:
function isa_add_img_title( $attr, $attachment = null ) {
$img_title = trim( strip_tags( $attachment->post_title ) );
$attr['title'] = $img_title;
$attr['alt'] = $img_title;
return $attr;
}
add_filter( 'wp_get_attachment_image_attributes','isa_add_img_title', 10, 2 );
Related Posts:
- Change the output for [gallery] shortcode
- How to Display an Image Uploaded through a Meta Box in a Template?
- Display different header images based on current page
- Why is wordpress searching for @2x images?
- How to create ‘Local’ filters for WordPress srcset sizes in template parts?
- HowTo: develop WP template with dynamic background image
- I want to rel=nofollow wordpress images
- Apply nextgen-gallery lightbox effect [closed]
- How to create a title images for different posts?
- How to get rid of undefined variable in previous post image
- How to add php to theme to show alt attributes
- second featured post not displaying on page [closed]
- Show uploaded images in full size
- wp_get_attachment_image_src and server path
- get_post_gallery_images returns thumbs . I want full size
- Remove P tags from images
- Any easy way to automatically set the first inline image in a post as the thumbnail?
- Why is wp_get_attachment_image not including “full” size in srcset?
- WordPress speed slow after .5 million single image post via wp-cli
- Generate fixed image sizes for different pages, eliminate sizes during upload
- Setup A Default Featured Image
- Find posts without featured image? [duplicate]
- How do I add a featured image to a single post page?
- How to disable the suffix “-scaled” which is being added at the end of each uploaded image?
- In media library images are not displaying run time [closed]
- How to get image extension from wp image editor object?
- Best option for photo/gallery handling?
- Frontend Post – Allow Only Image File Upload
- Add a new data attribute in tag
- File format of post image attachment
- SEO images in Nextgen Galleries
- Watermark images only for some users
- Can’t seem to attach uploaded image to post and set it as thumbnail
- Add an attribute to attachments
- Domain Change with New Image Sizes
- Why no images on a fresh WordPress installation?
- How to upload images in a specific folder using API
- How to stop thumbnail generation from some images and different size thumbnail generate
- wordpress (woocommerce) add image to media library programmatically python
- How can I filter image HTML to add schema.org attributes?
- How to get file URL from media library
- How to implement secure frontend image upload? [closed]
- How to translate get_intermediate_image_sizes?
- Change media URL (images)
- Problem with images when no dimension in the URL [closed]
- some images not appearing on the website after migration [closed]
- How do I get my main image to stretch the full length of the screen?
- WordPress images not cropping properly
- How to make my site use HTTPS for images or how to insert images as relative paths?
- Featured Image or Post Thumbnail Displaying on index.php?
- Clicks registering on Preview DNS site
- What did I do WRONG?
- Add retina “2x” in attribute “srcset”
- Change logo image condition based on url
- Hiding Media Source Links
- Random Characters in the end of every image url in post
- resize and crop thumbnail photos
- Broken thumbnails (sometimes) with TimThumb
- Can i have 2 separate Galleries on 2 separate pages each go to a DIFFERENT Attachment.php file?
- Why is my table background image not showing in wordpress?
- WordPress Media Library – how to “uncache” images
- How do you change the fetched image of a PDF uploaded into WordPress Media Library?
- Trying to change the URL of a product image once I upload it, but there seems to be no way to access the URL
- Is there a way to add a featured image to an image/file attachment page?
- Media Library Cleanup A Thought Exercise
- WordPress Multisite: Images moved to /sites/1?
- Site only working in browser where I created it
- wp_download_url() for dynamically generated image
- link not working in image section
- Images missing from Blog post page
- Page size too big due to images
- Full size image from srcset ALWAYS used on mobile DESPITE setting size of image in editor
- Run function before uploaded image is saved
- Are WP images responsive by default?
- Prevent WordPress from creating individual size images
- wordpress images not showing properly
- Keep the original ratio in a thumbnail image
- How can I set different banner images using background cover at different breakpoints?
- variable crop option with add_image_size()
- Plain image uploading – no links, no classes, no sizes
- Images with excerpt function
- How do I get resized thumbnails?
- How do I embed an image at actual size?
- Display ajax preloader for large images within posts
- Why is WordPress loading a different sized post thumbnail?
- Uploading Full Size Image vs Resizing Before Upload
- Insert image doesn’t pickup right size
- Storing images on a local site
- Adding Multiple Images to Sidebar Through Dashboard
- Tried everything but Facebook share button won’t load the post thumbnail
- Set image dimension for WP_Customize_Image_Control images
- Stop underlining image links
- How to hide image alt text/caption in Visual Composer?
- How to get attached image alt text in media.php?
- Why some images are not allowed to be edited only for thumbnails?
- problems with alt text not appearing in source code
- 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