How To Specify Image Dimensions In WordPress (GTmetrix Item)

Need to specify image dimensions in WordPress?

To fix specify image dimension errors in WordPress, locate the image that has this GTmetrix error and view it’s HTML. Add a width + height to the image’s HTML (provided by GTmetrix):

<img src="example.jpg" width="680" height="680" />

This just means you need to add a width + height to the image’s HTML or CSS. If an image does not have specified image dimensions, it will appear as an error in your GTmetrix report, and GTmetrix will even tell you the correct width and height that should be added to that image.

Specify Image Dimensions WordPress

 

1. Find Specify Image Dimension Errors In GTmetrix

GTmetrix only shows errors for the single page you test.

Run any page through GTmetrix and see which images have specify image dimension errors.

Specify Image Dimensions GTmetrix

 

2 Copy The Image’s Width + Height From GTmetrix

Next, copy the image’s width and height (provided by GTmetrix).

GTmetrix Image Dimensions

 

3. Locate The Image On Your Website

Now we need to locate the image on your WordPress site.

The WordPress visual editor automatically specifies image dimensions for you, so there’s usually no errors for images here. However, some areas of your website might not specify image dimensions automatically (possibly page builders, sliders, widgets, and hand-coded HTML or CSS). You need to learn which area of your WordPress site is giving you the errors.

Locate WordPress Widget Image

Specify Image Dimensions Widget

 

4. Add The Width + Height To The Image’s HTML

Once you locate the image, view it’s HTML and you’ll notice there isn’t a specified width + height. All you have to do is insert these into the HTML like this: width=”135″ height=”135″

Specify Image Dimensions In WordPress

<img src="example.jpg" />

<img src="example.jpg" width="680" height="680" />

 

5. Retest The Page In GTmetrix

Save changes and rerun the page through GTmetrix. The image that had errors should be fixed.

Specify Image Dimensions WordPress

 

6. Use The Specify Image Dimensions Plugin

The Specify Image Dimensions plugin scans your website for all <img> tags that are missing a width and height, then adds them automatically. However, I didn’t have success with this plugin.

I have gotten so many people looking for a specify image dimension plugin that actually works and fixes all specify image dimension errors on the site. For the love of god, if you’re a plugin developer please create this! Unfortunately, I (and my readers) have not found one that works.

Specify Image Dimensions plugin

 

7. Fix Specify Image Dimension Errors On Multiple Pages

Want to bulk fix images that appear on multiple pages?

You can use the Better Search Replace plugin to fix your logo, widget images, and other images that appear on multiple pages without having to go through them individually. It can save time.

Step 1: Install the Better Search Replace plugin.

Step 2: In the “Search for” field, add the image’s HTML without the specified width + height. In the “Replace with” field, add the new version of the image that does include the width + height.

Step 3: Select the table(s) you want the plugin to scan and replace images on. You can do a dry run if you want to test it out, otherwise uncheck that option and click “Run Search/Replace.”

Better Search Replace Images

Step 4: The plugin will run and search/replace the image on all tables you chose. Once finished, Better Search Replace tells you how many tables it scanned and how many images it replaced.

 

Other Images Optimizations

I wrote a full tutorial on optimizing images in WordPress which includes:

  • Compressing images
  • Serving images through a CDN
  • Resizing GIFS
  • Removing EXIF data
  • Lazy loading images + videos
  • Cloudflare Mirage, Polish, Hotlink Protection

Image Optimizations In GTmetrix

Looking For More WordPress Speed Tutorials?
Here are other tutorials I wrote:

I also have an awesome video on WordPress speed optimization:

I hope this tutorial helped you and you don’t have specify image dimension errors anymore!

 

Frequently Asked Questions

How do you specify an image's dimensions?

Find the error in GTmetrix and copy the image's width and height (provided by GTmetrix). Locate the image in WordPress and view it's HTML. Add the width and height to the image's HTML. Example: width=”680″ height=”340″

Can I use a plugin to specify image dimensions?

Most specify image dimension plugins don't work, but you can try Better Search Replace to bulk fix images that appear across your site.

How do you Optimize Images in GTmetrix?

This means you need to losslessly compress images using a plugin like ShortPixel or Imagify. I use ShortPixel.

How do you serve scaled images?

If you have serve scaled image errors in GTmetrix, it means you are uploading images that are too large and they need to be resized to the correct dimensions. Your sliders, portfolio images, widget images, full width blog images, and other sections of your website call for specific dimensions. You need to resize images before uploading them so they fit those.

Drop me a comment if you still have questions.

Cheers,
Tom

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments