0

I'm running a family wordpress blog: http://www.kjirstiandtom.com

We have a lot of pictures we put up for family. I'm using the twenty-eleven theme, which I love. I did minor css edits to change colors and fonts, but it's otherwise pretty much stock.

Resizing works great... until you get really skinny (e.g. iphone screen). if you resize the browser window, you see that the pictures width starts to resize, but the picture height does not. Any tips?

Thanks!

1
  • Interesting... Removing the inline height attribute in the image tag seems to solve the issue. I did also notice that your images don't have the default classes that images will generally have when inserted. I don't know if that is relevant, but an observation...
    – Dan
    Feb 3, 2013 at 6:29

2 Answers 2

0

Here is a quick function to remove the width and height attributes from images which should resolve your issue.

function _remove_img_dimensions_WPA84292($html) {
  $html = preg_replace('/(width|height)=["\']\d*["\']\s?/', "", $html);
    return $html;
}
//for new images
add_filter('post_thumbnail_html', '_remove_img_dimensions_WPA84292', 10);
add_filter( 'image_send_to_editor', '_remove_img_dimensions_WPA84292', 10 );
//for images already inserted into posts
add_filter('the_content', '_remove_img_dimensions_WPA84292', 10);
0

try to add CSS

.entry-content img { max-width: 100%; height: auto; }

This should set image height automatically and fix your issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.