First, I’m not an online developer or a technical man who is aware of a lot about CSS, HTML, JS, and all the things else.
So, don’t count on to learn all of the technical jargon regarding CSS, picture attributes, width, top, side ratio, and many others., on this submit.
I’m only a blogger who by chance finds a lazy man’s manner so as to add specific width and top to picture components error warnings in Google Pagespeed Insights.
Belief me, I’ve learn numerous posts and Google paperwork on find out how to add specific width and top to picture components, but it isn’t working for me. Most posts are for superior internet customers who can play with codes.
And as per WordPress plugins, most plugins I’ve tried fixing the problem don’t work.
However surprisingly, the tactic I present you right here is so easy that you just’d surprise why you by no means considered it as a result of you have already got the device to repair the picture components’ top and widths in your WordPress Gutenberg editor.
Sure, that’s true.
WordPress gave you the device to repair it without having plugins or including CSS attributes.
At once, let’s go straight to it.
Fixing Picture Components do Not Have Specific Width and Peak
Word that this methodology solely provides picture components’ specific top and width on particular person posts. It doesn’t work routinely, fixing all affected photos in your WordPress web site on the fly or background.
Earlier than you try and specify the peak and width of the picture components, run a Web page Pace Perception take a look at to pinpoint affected photos on a person submit.
Word their picture alt and the precise submit you wish to repair.
Right here is an instance of the error message checking with one among my web site posts.
As you may see within the picture above, many photos are lacking specific width and top components.
How will we repair this?
Now, open the submit in your WordPress Gutenberg editor. Click on the picture you wish to add specific width and top dimensions, and be sure you’re on the block tab within the right-side panel.

Take note of the small print within the picture above.
Within the picture dimension part, set the picture components’ top and width to 75%. The choice is already there, so you do not want to enter any settings.
Repeat this step for all the pictures on that specific submit with the picture components error discover.
After specifying the picture width and top to 75 %, replace the submit to permit the adjustments to take impact.
Return to the Pagespeed Insights testing device, and rerun the take a look at.
After the take a look at, scroll the web page to test if the error resurfaces. The warning ought to now go away in case you observe the steps accurately.
That’s it. I instructed you the method is so easy you’ll surprise if it’s going to work. It labored for me, so I consider it ought to give you the results you want, too.
If you happen to see any picture with the warnings discover, assessment the submit to see that you just’ve set the peak and width to 75%. And repeat the method to repair it.
Who Ought to Use This Technique?
This methodology could be appropriate when you’ve got a small web site with a couple of hundred pages.
I say this as a result of working the web page velocity and efficiency take a look at for every submit is much less time-consuming and difficult than when you have got hundreds of pages.
In case you have a WordPress weblog with lower than 300 or 400 pages, you may shortly test by every submit for picture components lacking top and width attributes.
Moreover, doing this on giant web sites with hundreds of pages might be difficult. On such websites, you want a system routinely including native heights and widths in pixels for photos as attributes.
This methodology described on this submit doesn’t set it and forgets it. You must discover pages in your web site with picture top manually and width attributes errors.
Some WordPress Plugins to Attempt
If you happen to’re in search of an automatic solution to repair the picture components’ width and top attributes warning in PSI, listed here are some plugins I got here throughout throughout my search.
Specify Lacking Picture Dimension
I didn’t do that plugin as a result of it was final up to date over a 12 months in the past. However from a dependable supply, I learn the plugin was dependable when it was maintained.
The plugin scans the HTML of the online web page, in search of photos with lacking width and top attributes. After discovering photos with lacking dimensions, it makes use of the getimagesize()
operate to find out the picture dimension.
Then, it provides the width and top attributes to the pictures.
In case you have no drawback utilizing a plugin’s final updates over 12 months, you need to do that plugin. From a couple of consumer opinions and its description on wordpress.org, the plugin appears definitely worth the attempt.
WP Rocket
WP Rocket is one other good plugin to automate the fixes for lacking picture dimensions. Of their current replace, they’ve included this characteristic within the Media Tab.
Go to the WP Rocket Media Tab setting, scroll down the web page, find the characteristic, and test the field.

That’s all you might want to repair Picture components wouldn’t have specific width and top in GTmetrix, PSI or some other testing device.
After checking the field and saving the setting, WP Rocket will scan your web site HTML for photos with src
attributes however lacking width and top.
Then, utilizing the PHP operate getimagesize
, the plugin will add the lacking top and width dimensions utilizing the information.
Nevertheless, you might want to learn this characteristic’s documentation or assist article. This operate has limitations, as there are cases the place it doesn’t work on particular photos.
First, the pictures have to be hosted in your web site for the operate to work. Although you will get it to work on externally hosted photos utilizing the helper plugin, it’s going to improve the time to generate the cache.
One other concern is that the characteristic received’t work on photos with the width and top set to “auto” values. Additionally, it is not going to act on photos with question strings of their URL and dynamically injected right into a web page load.
To be taught extra about WP Rocket add lacking picture dimension characteristic limitations, advantages and the way it helps with Cumulative Format Shift, read this post.
FAQ – Add Specific Width and Peak to Picture Components
Positive, I do know you have got extra questions in your thoughts. So, I’d put together a couple of questions and solutions you would possibly wish to try.
In case your query remains to be not answered under, depart me a remark and I’ll attempt my greatest to supply the reply.
What Are the Plugins for Picture Resizing in WordPress?
Smush compresses and optimizes photos to enhance loading time with out sacrificing picture high quality.
EWWW Picture Optimizer routinely optimizes photos to enhance web site efficiency whereas providing conversion to next-gen codecs like WebP.
ShortPixel is one other WordPress plugin that optimizes and resizes photos, decreasing their file measurement to enhance web site velocity and general efficiency.
Nevertheless, the perfect plugin that fits your wants is determined by your web site necessities.
How do I repair the width and top of a picture in CSS?
Use the under CSS code:img
width: 600px; /* Set the specified width to 600 pixels */
top: 300px; /* Set the specified top to 300 pixels */
You must modify the picture values (e.g., 600px and 300px) to your most well-liked dimensions. Additionally, do not forget that mounted picture dimensions might trigger the picture to lose its side ratio in the event that they don’t match the unique proportions, inflicting extra web page structure shifts error in web page velocity testing instruments.
How do I repair the width and top of a picture in HTML?
The best manner is to make use of the “width” and “top” attributes within the “img” tag to repair the width and top of a picture in HTML.
<img src=" width="300" top="200" alt="Picture description">
Substitute “your_image_url.jpg” together with your picture’s precise URL or file path. And modify the width and top values to your required dimensions. Once more, mounted picture dimensions could cause structure shifts if the picture’s side ratio doesn’t match the unique settings.
Conclusion
Fixing picture components that wouldn’t have specific width and top could be difficult to resolve, particularly on image-heavy websites. However with persistence and particular consideration to the web page velocity testing instruments suggestions, you may repair the affected photos your self.
The answer on this article is appropriate for small websites and can work 100% of the time for particular person pages.
If you wish to repair the lacking picture dimension in bulk and routinely, you need to attempt WP Rocket or different picture optimization and resizing plugins listed within the FAQ part.
I hope this text helps you resolve your efficiency subject and enhance your web site Cumulative Format Shift (CLS) error.
#Lazy #Add #Specific #Width #Peak #Picture #Components