Focus on cloud service provider activities
Notes on website operation and maintenance

WordPress deletes the height and width parameters of pictures in batches

Sometimes the WordPress pictures we collected and edited have width and height parameters, and we need to delete them in batches. Here, we can directly use such a piece of code.

 //Eliminate the default image width and height 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; }

 

Vote for you
Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( zero )
Do not reprint without permission: Lao Zuo's Notes » WordPress deletes the height and width parameters of pictures in batches