Created
October 10, 2014 01:43
-
-
Save michaelmusgrove/a0f6231b53626d2f60f3 to your computer and use it in GitHub Desktop.
Make images responsive - create a shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[responsive]<img src="image_url" alt="alt" title="title" />[/responsive] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function responsive_images($atts, $content = null) { | |
return '<div class="image-resized">' . $content .'</div>'; | |
} | |
add_shortcode('responsive', 'responsive_images'); | |
Once done, open your style.css file and add those CSS rules: | |
@media only screen and (max-width:767px) { | |
.image-resized img { | |
width:100%; | |
height:auto; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment