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
- Removing website URL in comments causes misalignment of submit button and tickbox
- How can I add pagination and how can I change thumbnail size?
- Count the number of times the search form template gets included on a page
- Displaying theme options in css
- Show post in slider
- PHP code inside shortcodes
- Limiting woocommerce line_total decimal length
- Add itemprop Schema.org Markup to li Elements in wp_nav_menu
- Problem adding class to body_class
- Run a filter when a walker runs
- How can I use wp_insert_comment to write a comment when a post is edited?
- Using Multiple Submit buttons to trigger customised php functions
- Removing unneccessary p-tags (Not every p)
- Add a custom stylesheet for BlackBerry
- How to remove the excerpt in the Dzonia Lite theme
- comments_number display outside specified span
- Choose To Display Post Views With An Options Panel
- Prevent Data Resubmission On Page refresh
- Set WordPress Default Template
- Echo URL of large version of Featured Image
- How can I hide Home in my menu in a specific page?
- Shortcode content filter?
- Missing sidebar parameter “fix” – before_content
- Get different images for mobile and desktop with php, advanced custom fields without using js and ajax
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- How do I display a user’s previous orders as a select box option on a product?
- How Display Posts on category
- Using file_get_contents with Gravity Forms uploads folder to create images in the media library returning false
- allow subscribers to see private posts without plug in
- Replace word in “the_content” only for index.php
- How do you add customer capability after Woocommerce purchase?
- How to get specific image in media library with php
- Function set default image when image not present
- Custom location for attached images
- WooCommerce – Reset quantity input field when variation changes
- Query all posts of a custom taxonomy term
- get current product name in functions.php
- Get first URL from post content
- Setting custom canonical urls
- Handling Body class based on Template
- Trigger popup in a php if/else statement
- Setting a cookie upon specific URL visit
- Get_avatar filter?
- Can’t get page content in WordPress
- WordPress child theme fails to override parent navigation menu in /inc/structure/header.php