• Hi there! I’m new to wordpress and php so be gentle.

    I can’t figure out how to return a featured image in get_the_post_thumbnail and the_post_thumbnail without any size attributes attached to it. My design is completely responsive and having the height attribute on the image does not lend itself to be resized.

    I would still like to take advantage of choosing which thumbnail size to return – just without the size attributes in the image tag.

    I’m sure there is a way to do this. Any help is appreciated!

    To be clear, I’d like to turn this:

    <img width=”400″ height=”200″ src=”https://localhost:8888/wp-content/uploads/2013/07/hero_2-400×200.png&#8221; class=”attachment-post-thumbnail wp-post-image” alt=”hero_2″>

    into this:

    <img src=”https://localhost:8888/wp-content/uploads/2013/07/hero_2-400×200.png&#8221; class=”attachment-post-thumbnail wp-post-image” alt=”hero_2″>

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter bkuethen

    (@bkuethen)

    This seems ridiculous, but this is what I’ve used:

    <?php
     if ( has_post_thumbnail()) {
       $full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full');
       echo '<img src="' . $full_image_url[0] . '" title="' . the_title_attribute('echo=0') . '" />';
     }
     ?>

    I’m not sure if it will work the same for get_post_thumbnail.

    Thread Starter bkuethen

    (@bkuethen)

    Is there a cleaner way to do this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Post Thumbnail Without Width and Height’ is closed to new replies.