Stop wordpress from hardcoding img width and height attributes

I’m wondering if there’s a simple way top stop WordPress automatically hardcoding featured image height and width attributes, other than using regex…

As I’m using a flexible grid for my project (who isn’t!) this is causing some funky image issues.

8

You can get featured image URL and add it to your content manually, eg:

<?php 
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'thumbnail' ); 

if ($image) : ?>
    <img src="https://wordpress.stackexchange.com/questions/29881/<?php echo $image[0]; ?>" alt="" />
<?php endif; ?> 

Leave a Comment