something like this can be useful:
function image_tag($html, $id, $alt, $title) {
return preg_replace(array(
"https://wordpress.stackexchange.com/".str_replace('//','//',get_bloginfo('url')).'/i',
'/s+width="d+"/i',
'/s+height="d+"/i',
'/alt=""/i'
),
array(
'',
'',
'',
'alt="' . $title . '"'
),
$html);
}
add_filter('get_image_tag', 'image_tag', 0, 4);
Related Posts:
- How to modify an image block in Gutenberg WordPress 5?
- Edit srcset and sizes attributes in Gutenberg image, cover and gallery – blocks
- wp_get_attachment_image_attributes not working for me
- How to disable thumbnail filter for a specific template part or image size?
- WordPress Theme Preview Image
- Get the first image from post content (eg.: hotlinked images)
- How to remove the Theme Customization Button from the dashboard and themes options page?
- Change admin bar to default:off
- How can I set image sizes and still have responsive images using the srcset attribute?
- Add default Backgrounds
- Run shortcode before filters
- Add class to before_widget for all widgets with a dropdown and a counter
- add_image_size is scaling, even though crop is set to true
- Featured Image in 4.4 should be larger on mobile device
- How to use the responsive images feature from WP 4.4 in your themes
- Unexpected width and srcset attributes for the_post_thumbnail();
- Get password when user registers and save it sha1 into database
- How wordpress handle upload images and how to use them in the code
- Replace Home with image link inside custom header menu
- Featured Image Size
- How to set dimensions of the post thumbnails (featured images)
- customizing the_password_form filter
- WordPress Genesis Child Theme Filter divs
- Change file name from wp_generate_attachment_metadata
- A mystery 300px image size
- Custom Field returning Numerical Value for Image rather than URL
- When trying to override plugin’s function by theme, my filter executes two times, I want it to run only a single time
- Why an arugment is missing in wp_get_attachment_image_attributes?
- Menu item added in wp_nav_menu_items filter is never highlighted
- How to make a local cache of mshots images
- How do I Add images uploaded in the post to a default custom field
- Pass variable to hook. Its possible?
- attachment.php code or tutorial
- Change “Thumbnail”, “Medium” and “Large” image sizes using functions.php?
- image url relative path not working in css file
- WordPress Media Uploader in page template (On Front-end)
- WordPress taxonomy and archive custom class
- Responsive Images – crop don’t seem to work
- Filter categories used with Custom Structure Permalink
- Inserting images in multiple posts native gallery
- Can I get the ID of an inserted / linked image?
- Add attachment for all images in post
- What is the meaning of WordPress’s recommended css classes and where are they applied?
- Redirect to another page using contact form 7? [closed]
- How to wrap all titles generated by Gutenberg “Heading” block with tag
- Replace single_template filter with what for default posts?
- Getting Different Size Of Attachment Images
- In creating a theme, how can i allow a user to change an image outside post/page content?
- How to rotate every letter in a title
- How To Pick Custom Size Of Uploaded Image In Theme Via the_post_thumbnail();?
- Change image size depending on page
- How to obfuscate theme directory URLs
- Are seven additional image sizes are too many?
- CSS class on last post in loop ( custom query )
- How to change footer credit text in Twenty Twenty One theme with a hook?
- how to retrieve the image title for image Post Format
- Use a filter on menu items that have children
- Modify available templates (in dropdown)
- Theme logo metadata into template file
- tiny_mce_before_init: ‘exact’ => true has no effect
- How to conditionally add a wp_filter
- Filter didn’t work on content class (hybrid_post_attributes)
- How to set default values for edit_post_link() in my theme?
- Stop WordPress from showing images on non post pages
- How to make excerpt image be full size instead of thumbnail?
- How to add cropped custom header image?
- Is there a way to serve different resolution images to different devices?
- How can I scale down the width of images in bulk that are embedded in posts throughout the site?
- Dynamic Image Links Depending on Excerpt/’Single Post’ View
- Designing a custom archive.php inspired by the Autofocus theme
- Related Post Category Filter
- Pagination don’t work with active filters
- How to register dynamic settings in WordPress Customizer?
- restrain filter on get_the_excerpt to queried item in stead of current post
- Post Featured Image Custom Sizing?
- Image cropping isn’t working correctly when using Offload Media
- WordPress wp_get_current_user returning blank values until refresh
- Alt header logo and link for specific pages
- Responsive Images with art direction
- Customizer Image-Picker Preview Not Working
- Uncaught Reference error in Retina.js
- Make a custom field in admin post.php read only
- Can’t upload images on new theme
- Caption Shortcode: what filter to change the image size?
- image sizes – finding and removing
- Hook in parent theme Menu function
- How do I remove p tag *insertions*? Disabling `wpautop` removes manual tags
- How to add custom nav_menu_css_class to certain menu only?
- Adding a Class to an Getting From Post Content
- what is do_action(); in wordpress? [duplicate]
- Suppress the_content filter in a nested loop
- How do I keep images in posts below a certain size without editing the post?
- Any disadvandages if I style the wordpress align classes without img and .wp-caption prefix
- the_post_thumbnail fetches wrong image
- apply_filters to featured image
- Custom image size doesn’t work
- How can I add a single image from a gallery into the page header?
- Isotope overlapping .items because of featured images – HELP! [closed]
- Custom Theme functions.php – Using add_settings_field and input type=”file” to set custom logo
- I want to resize post featured image without cropping image. How?