Posted By

f6design on 11/30/11


Tagged

wordpress images


Versions (?)

Wordpress: Omit width/height attributes from img tag


 / Published in: PHP
 

URL: http://wordpress.stackexchange.com/questions/29881/stop-wordpress-from-hardcoding-img-width-and-height-attributes

This is an example of omitting the width and height attributes from a thumbnail img tag in Wordpress. Useful if you are working on a responsive design. Use inside The Loop.

  1. <?php
  2. $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'thumbnail' );
  3.  
  4. if ($image) : ?>
  5. <img src="<?php echo $image[0]; ?>" alt="" />
  6. <?php endif; ?>

Report this snippet  

You need to login to post a comment.