Skip to content

Instantly share code, notes, and snippets.

@sanjaybhowmick
Created September 10, 2015 02:53
Show Gist options
  • Save sanjaybhowmick/fef398debd714202524a to your computer and use it in GitHub Desktop.
Save sanjaybhowmick/fef398debd714202524a to your computer and use it in GitHub Desktop.
Setting up responsive image in WordPress
<?php
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
function remove_thumbnail_dimensions( $html )
{
$html = preg_replace( '/(width|height)="d*"s/', "", $html );
return $html;
}
?>
/* Images */
.entry-content img,
.comment-content img,
.widget img {
max-width: 97.5%;
}
img[class*="align"],
img[class*="wp-image-"] {
height: auto;
}
img.size-full {
max-width: 97.5%;
width: auto;
}
// Caption
.wp-caption,
.wp-caption-text {
max-width: 97.5%;
height: auto;
width: auto9; /* ie8 */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment