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
- wp_set_object_terms and arrays
- How to get the original price of the product in woocommerce?
- How to use WordPress (PHP) functions in AngularJS partials files?
- Different background-image by category
- enqueue multiple Google fonts with multiple weights and styles (italic)
- What is the fastest way to load PHP functions that are only used in one theme template?
- Can’t load WP function into external function
- WSoD being caused by this piece of code
- How to complete two other input fields, completed the first
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- Scrape external webpage for first image and add it to new post
- jQuery code not working when included in functions.php
- Fatal Errors on pluggable.php
- Log in / Log Out Custom Button
- Make Current/Active Page Number a Link (WP_LINK_PAGES)
- How to make modifications only to certain elements of an HTML string on the server-side?
- Custom Pagination is Broken
- Sidebar not appearing in footer, but it appears everywhere else!
- How to create table in wordpress without plugin? [closed]
- List post by title length
- Deactivate a plugin on wp version
- the_post_thumbnail issues
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- Uses for function: wp_update_user
- Add other class content with reference class value
- How do I integrate vanilla Javascript to a wordpress website?
- Exclude category from function – PHP
- How to display post meta bellow every posts
- Hide a specific category title from displaying on site
- Handling form actions in WordPress
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- Shortcode’s output to use as other shortcode’s parameter
- Thumbnail wouldn’t scale to size properly
- PHP script to redirect traffic based on website accessed
- How to remove title tag with this filter
- Why transition_post_type hook is called twice for the same post?
- Retrieving specific images from Media Library
- List sibling pages widget, exclude current page
- Permission error on plugin save
- Display default WordPress login/registration form into a modal window
- How do I use CSS or PHP to customize WordPress Form Manager Plugin Table?
- Pull GET parameter from URL in functions.php
- How to NOT override inline css rules
- Adding Gravity Form With if(is_page) Is Not Working
- Load files content [closed]
- Why a class property becomes empty?
- Hide category by tag
- add_rewrite_rule image from /images/site2/favicon.ico to /favico.ico