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 add php to theme to show alt attributes
- 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
- second featured post not displaying on page [closed]
- Show uploaded images in full size
- show hide image script after 4 seconds [closed]
- How to delete resized (cropped) image uploads and prevent future resizing?
- How to display a page’s featured image?
- Featured image shortcode
- Cropped featured image replaces original image in gallery
- Change html structure of all img tags in WordPress
- Use Media upload in custom widget on wordpress 3.5
- Theme Customiser Image Control
- How to remove title attribute from gallery links and images
- How to increase media image scale limit?
- How to default all users to no link for attachments?
- How to output placeholder image if no featured image set?
- Cannot access the thumbnails of attachment images… Cannot find the reason
- Why html tags are being appended to my pictures?
- Set a background color per image added to a post
- add_image_size() to crop images into squares?
- How to create a simple slideshow out of a post image gallery?
- How Do I Delete All The Images from WordPress
- Consolidating two websites into one, but migrated images not appearing in Image Library
- Lazyload post thumbnails
- Is there a way to change wordpress image resize settings?
- wordpress media library shows empty images
- Is my code is right to make image shortcode
- Adding different backgrounds for different pages
- Mobile Featured Image Bug
- How to remove p tags around img and iframe tags in the acf wysiwyg field
- If Media Type .GIF
- Pull images from the gallery
- Migrate image from my old blog
- the_post_thumbnail() image sizing problem?
- Imagick vs GD colour issues on image uploads
- Get ALT attribute from title post (code not work)
- How to configure sub-domain for images on Debian Apache VPS?
- Why it doesn’t show media urls on rest Api? (WordPress)
- Resize images in existing posts
- Enable custom logo upload if logo is not in header
- WordPress PNG compression issue
- Is there any way to Integrate WordPress with Imgur for Image Hosting
- “Unable to create new image” error in wordpress dashboard image editor
- Fallback image size when using wp_get_attachment_image_src / full size compressed image
- How can I add a ‘Click to Enlarge Image’ feature, with the enlarged image opening in a popup?
- Is there a resolution limit in image resize?
- How to remove header images from displaying (not css or editing)?
- How to display original unmodified thumbnail
- One picture belonging different galleries?
- Setting default image size
- Rebuild thumbnails via WP Cli – how?
- How can I make an image full width inside a paragraph which is 70% (text) [closed]
- Images uploading from media going in wrong folder
- Row background image not showing in mobile browser served from wamp local host
- Get ID for previous/next image link
- How does wordpress name resized image copies?
- adding image to post thumbnail from another server
- Logo is not being displayed in header (Twentytwelve)
- Simple Local Avatar Plugin
- Pagination between images (active/inactive)
- Web App mode leaves users stranded when following image links when using WPTouch with W3 Total Cache [closed]
- My authors need to be able to preview their upload images and manipulate and scale
- Lazy Loading of all Images
- wp_get_attachment_image – enable width and height attributes for an SVG image
- How to remove image size inline style in article and include caption
- Register an embed handler for self hosted images
- still need help-images inside wp-content/ uploads/ are not showing up in my media library and uploaded using FTP protocol
- Get image thumbnail size urls in media library
- WordPress is showing blank lines instead of images
- Export wordpress image ID based off keyword search
- After moving a site to new hosting, not all images are showing in media library
- Load only imagens resized in custom page
- How to inject alt and title attributes for every image in each post into HTML?
- Custom Background for each page and post
- How to see previous –next image option in the theme?
- How can the alt be added to this wooCommerce category image?
- Getting the Select and Crop Functionality Using Custom Fields
- Displaying “alt” attribute text as captions?
- Need help making my homepage blog image smaller than my post image
- After I upload a file to library its name converted to dashes
- Image to only show up in the single post page, not on the blog/home page
- How do I display image files as links?
- wp_get_attachment_image_src() does not return what I want
- 3.5.x Theme Customize: Handling Custom Control Requests
- Add category description to list of category with taxonomy image
- Wrap a post image with a div if it doesn’t have a caption
- Images in sub-pages fail to load
- How do add custom class and id to the that is generated from media gallery insert image into post [duplicate]
- How do I get the URL of only the first picture in a WordPress post?
- Adding different classes to different images depending on size for fine control of image layout in posts
- Images have dissapeared from media library and site