You can use a filter to remove height and width attributes from images, as explained in this CSS Tricks. Place the following in your themes functions.php file.
add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 );
function remove_width_attribute( $html ) {
$html = preg_replace( '/(width|height)="\d*"\s/', "", $html );
return $html;
}
Related Posts:
- How do I change/modify the_post_thumbnail(); html output?
- Best way of adding CSS which can be manipulated by the user via theme option panels?
- WordPress loop specific thumbnail size
- Using PHP to toggle stylesheet and header image, set in cookie
- How to make thumbnail image fit into a div where image dimentions are completely different?
- How to scale image with equal width and height without distortion?
- How to Display Image Meta underneath EVERY image in EVERY post
- Shortcode content output but not in correct place
- How to stop featured image thumbnail [set as background image] on blog index page just repeating same image across all posts
- Hide Hamburger Menu On Specific Page (Front Page/Home Page)
- How to style options page in dashboard?
- Set the background to a default image if there isn’t a specified “featured image”
- Css loads very slow [closed]
- responsive.css in the WordPress should be prioritized
- Redirect to another page using contact form 7? [closed]
- How to make container class in PHP
- Creating a mobile site by adding a new class to the body tag from functions.php
- CSS change in woo commerce Place Order Text [closed]
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Else/If Statement to Display Photo Descriptions
- Fallback image URL if no featured image exists via a shortcode function
- Get the alt text of the image in a array
- how to changes mobile menu toggle breakpoint in WordPress
- Add Featured Image to Existing Post
- PHP function for horizontal Woocommerce thumbnails and badges
- not outputting medium size image URL
- Problem with displaying CSS Stylesheets – Am I adding them correctly in my wordpress child theme?
- How to put 2 php codes in functions.php without site crashing
- I got big white screen when i attach main style sheet of Html in functions.php
- Add a default style if no Featured image is selected
- How to link all featured images to custom url in single.php for only non-logged-in users?
- Site title not showing. Please help me
- PHP/CSS: Shortcode won’t display correctly, and only displays in the head (before content)
- Add class for the_post_thumbnail_caption()
- Displaying POST content with HTML tags and all
- Highlight Single Page Ancestor
- insert thumbnail image from php script
- Can’t put a hyperlink on Featured Post’s Image
- Styling admin page rows in order of importance (checkboxes)
- How to have Function of a plugin using global vars into a shortcode?
- Overwriting a Shortcode
- featured post as div background
- Cant get theme to change footer color through theme customizer
- How to add margin underneath woocommerce total price amount -> productpages
- How do I get Roboto Google Font to display normal font-style? [closed]
- Integrating CSS Into a WP Function Call [closed]
- Load slideshow.css file only if Slideshow is checked / on
- add if statement to the featured image
- Sorting Problem
- Remove default Image Sizes
- Add attribute to featured image with filter (wp_get_attachment_image_attributes)
- Generate and upload screenshot as featured image for user-submitted post
- How do I make a shortcode to display Dokan seller badge list?
- How can we upload custom page files?
- Calling a PHP function from a menu item
- Hide or Show Read More Button by Content Area
- How to overwrite youtube embed?
- Generating add_settings_section() calls dynamically
- Remove query string specific key value
- is_page “range” for if statement?
- WordPress child theme fails to override parent navigation menu in /inc/structure/header.php
- Converting HTML Template to WordPress Theme
- Add data attribute to each li in menu
- Prev/Next child navigation for current page modifications?
- Adding rel tag to all external links
- Prev/Next Links Broken on Static Front Page Pagination
- How do I check or test a WordPress Auto Year Change Script?
- Is there a built-in function to generate multiple paragraph tags based on a string with new line separators?
- How to add no follow to specific links?
- How to hide the author box of a specific user?
- Add date before entry title in Twenty Twelve
- WordPress theme showing blank page
- The additional fee for the COD payment method not visible in the front-end
- PHP identify duplicate words in a text string against a list of words
- How to access all meta data for RSS feed?
- Why Is Number of views on wordpress single post wrong?
- How to add and subtract user meta values after post meta update
- Multiple AJAX handler functions conflict in functions.php
- add another variable to php function
- How to remove get_header From all single pages in wordpress with functions.php without plugin?
- How to hide a div section when user is logged in, in single product woocommerce
- Send POST request to Flask app from functions.php file
- How to let mobile navigation menu close when link is clicked?
- Fix hover images blink
- How to auto-generate random numbers in username?
- Remove generated category and tag class names from woocommerce product & blog listings markup
- Blog Image and Title in Right Sidebar
- remove public static function wp_link_dialog()
- Find the method which AJAX GET calls
- Calling PHP function doesn’t work in index.php
- Revision History for Entire WordPress Site
- Trouble using wordpress functions in a pop-up modal form
- admin-ajax.php loading many times
- how can I make content from a plugin hidden when user is logged in? [duplicate]
- How to insert the first letter in uppercase [closed]
- how to display custom taxonomies in front page
- Custom WordPress Function – Adding items from Foreach Loop into an array and Updating Field based on array of IDs (ACF + WooCommerce)
- Create custom API endpoint to change custom header image
- Change WooCommerce Order status from frontend form submitted data
- Show Login Errors In WordPress/Elementor (Code “works”, but breaks site)