Quick Way To Make WordPress Images Responsive

< 1 min read

Making the images in your posts and pages on your WordPress website is actually quite simple. Making your images responsive is a case of allowing your images to adjust to the width of their container. For example, when an image is viewed on a desktop computer, it’s width can be 100%, but when viewed on a tablet or smartphone, the same image at 100% may be overkill. The solution is to make the image scale to a percentage of the original when viewed on devices with a smaller screen resolution. The first thing you need to do is to copy the following code in to your themes function.php file. You can do this by navigating to “Appearance” > “Editor” and opening your “Theme Functions” (functions.php) file.

function responsive_images($atts, $content = null) {
     return '
‘ . $content .’

‘; }

add_shortcode(‘responsive’, ‘responsive_images’);

This basically adds a shortcode to your WordPress website that when wrapped around your image code will make it responsive. After you’ve added the above code to your function.php file, save your changes and open up your themes style.css file and add the following code:

@media only screen and (max-width:767px) {
    .image-resized img {
        width:100%;
        height:auto;
    }
}

In some cases, your theme might have a section in it’s “theme options” that will allow you to input custom css. The 100% width above can be adjusted to suit your needs e.g. 50% of the container width might work better for your images. Now that you’ve edited your functions.php file and themes css, you can use the following shortcode to make an image responsive.

[ responsive ]< img alt="my image" src="http://www.mydomain.com/path-to-image" width="100px" height="100px" />[ /responsive ]

Note: remove the extra spaces from the responsive shortcode & img tags!

Published in

Tristan Whittaker

Tristan Whittaker is a respected website consultant and digital strategist with more than 20 years of experience shaping how UK businesses grow online. As the founder of Infinity3, he has built a reputation for creating high performing websites and digital systems that genuinely move the needle for the companies he works with. Tristan is known for combining deep technical knowledge with a clear, practical way of explaining what really matters. His work has helped hundreds of businesses improve their visibility, streamline their processes and build a stronger online presence with confidence. Clients value his honesty, his attention to detail and his ability to turn complex ideas into solutions that simply work.

Leave a Comment





Need Help Taking the Next Step?

Let’s Put These Ideas to Work for Your Business

We don’t just talk about strategy — we implement it. Whether you’re looking to improve your SEO, launch a new website, or explore AI-powered tools, we’re here to help.

Let’s chat about how Infinity3 can support your next move.