Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared Managed Cloud India
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Best lists Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

SEO & AI search · Guide

How to Optimize Images for SEO in WordPress

Short answer

To optimize images for SEO in WordPress, use WebP or AVIF with a JPEG fallback, write short descriptive alt text and file names, let WordPress serve the right size with srcset, compress each image before upload, and lazy-load everything below the fold. Images are usually the largest files on a page, so getting them right is the fastest way to improve both search visibility and load time.

Key takeaways

  • Google supports BMP, GIF, JPEG, PNG, WebP, SVG and AVIF, and it only indexes images in a normal img element, not CSS backgrounds.
  • Use WebP as the default format, AVIF for key photos, and keep a JPEG or PNG fallback.
  • Alt text is the most important image metadata; describe the image plainly and never stuff it with keywords.
  • WordPress adds srcset and sizes automatically since version 4.4, and scales images wider than 2560 pixels down on upload.
  • WordPress lazy-loads images by default since 5.5, but skips the first content image since 5.9 to protect Largest Contentful Paint.
  • A good Largest Contentful Paint is 2.5 seconds or less for at least 75 percent of page visits.

What does image SEO mean in WordPress?

Image SEO means making your images easy for Google to find, understand and show, while keeping them small enough to load fast.

Google shows images in regular search results, in Google Images and in Discover, and the same best practices apply to all three, per Google's image SEO guide.

Two things matter most: the image itself must be findable and described, and the page around it must give Google context. A sharp, fast image on a relevant page beats a large, slow one every time.

Images are often the largest files on a page, which is why they have the biggest effect on load time. Google's guide says high-quality photos appeal to users more than blurry ones, and sharp images can earn more clicks from thumbnails.

Which image format should you use?

Use WebP as your default, AVIF for your most important photos, and keep a JPEG or PNG as a fallback.

Google Search supports BMP, GIF, JPEG, PNG, WebP, SVG and AVIF in the src attribute of an img element, and the file extension should match the file type, per Google's image SEO guide.

WebP and AVIF offer better compression than older formats and should be used where possible, with a JPEG or PNG image as a fallback, according to web.dev's image format guide.

Pick the format by the job. Use SVG for logos, icons and simple graphics, since vector images stay sharp at any size.

Use PNG for screenshots and graphics with sharp edges. Use JPEG or WebP for photos, and AVIF when you want the smallest file and can accept slower encoding.

FormatBest forCompressionTransparency
JPEGPhotos, universal fallbackLossyNo
PNGScreenshots, sharp graphicsLosslessYes
WebPMost web photosLossy and losslessYes
AVIFKey photos, smallest filesLossy and losslessYes
SVGLogos, icons, diagramsVector, tiny filesYes

For animation, use a video element instead of a GIF. A short muted video is far smaller than an animated GIF of the same clip, as web.dev notes in the same guide.

Our next-gen formats guide shows how to serve WebP and AVIF in WordPress with a fallback.

How do you write alt text that helps SEO?

Describe the image in a short phrase, using the words a person would use to describe it out loud.

Alt text is the most important image metadata Google uses, and it also helps people who cannot see the image, including screen reader users and visitors on slow connections, per Google's image SEO guide.

Google uses alt text together with computer vision and the page content to understand what an image shows. It also uses alt text as anchor text when an image is used as a link.

Good alt text names the subject and the action: a Dalmatian puppy playing fetch. Bad alt text is either empty or stuffed with keywords, such as a long list of dog breeds and dog food terms. Google warns that filling alt attributes with keywords creates a poor user experience and can look like spam.

Write alt text in the media library when you upload the image, so every use of it carries the same description. Leave alt text empty only for purely decorative images.

Give each file a short, descriptive name with dashes between words, before you upload it.

Google's guide says a file name can give very light clues about the subject, and gives the example that my-new-black-kitten.jpg is better than IMG00023.JPG. Avoid generic names such as image1.jpg or pic.gif, per Google's image SEO guide.

Rename the file on your computer first, since WordPress keeps the file name you upload. A name such as wordpress-dashboard-settings.jpg tells Google and your future self what the image shows.

Keep names short and in lower case, and use only letters, numbers and dashes. If you localize your images, translate the file names too, keeping URL encoding rules in mind for non-Latin characters.

How do you serve the right size on every screen?

Let WordPress build responsive images for you, and pick the right size when you insert an image into a post.

Since WordPress 4.4, the editor adds srcset and sizes attributes to images automatically, so the browser picks the best file for the screen. WordPress creates thumbnail, medium, medium_large, large, 1536x1536 and 2048x2048 copies of each upload, as documented in the WordPress responsive images handbook.

The default sizes are 150 pixels wide for thumbnails, 300 for medium, 768 for medium_large, and 1024 for large, with the two larger sizes added in WordPress 5.3. The srcset list is capped at 2048 pixels wide by default.

Since WordPress 5.3, any image wider or taller than 2560 pixels is scaled down on upload, and the scaled copy becomes the full size. Upload images close to the size they will display, rather than a 4000-pixel photo for a 800-pixel slot.

Use the picture element or srcset when you write your own markup, and always include a fallback src attribute, since some browsers and crawlers do not understand srcset, per Google's image SEO guide.

Our image sizing guide explains which WordPress size to pick for each spot on your site.

How do you compress images without losing quality?

Compress each image before you upload it, and let WordPress handle the rest.

WordPress applies its own compression when it generates each size, and you can change the default quality with the wp_editor_set_quality filter, which works on a scale of 1 to 100, per the WordPress developer reference.

A compression plugin can do the work on upload, converting JPEGs and PNGs to WebP and shrinking every generated size. Pick one plugin for this job, not two, since two optimizers can fight over the same files.

Aim for the smallest file that still looks the same at full size. Export photos as WebP or JPEG at a quality setting around 70 to 80, and check the result at 100 percent zoom before you upload it.

Watch out for double compression. If WordPress already compressed a JPEG once, running it through another aggressive compressor can add visible artifacts. Upload the best-quality original you have, then compress once.

How do you lazy-load images the right way?

Lazy-load every image below the fold, and never lazy-load the hero image or the first image on the page.

Since WordPress 5.5, the core adds loading=lazy to all img tags that have width and height attributes, using the native HTML loading attribute, as announced on Make WordPress Core.

WordPress 5.9 refined this by skipping lazy-loading for the first content image or iframe on the page. An analysis of 50 popular themes showed this brought LCP improvements up to 30 percent faster page load, with a median LCP improvement of 7 percent from omitting the first image, per Make WordPress Core.

A good Largest Contentful Paint is 2.5 seconds or less for at least 75 percent of page visits, according to web.dev. Lazy-loading the hero image delays exactly the element that sets that score, so keep it eager.

Check the rendered HTML after you change a theme or plugin. If your hero image carries loading=lazy, remove it with the theme's own setting or the wp_get_loading_optimization_attributes filter.

How do you get images into Google Images and Discover?

Put each image in a normal img element, near relevant text, on a page that matches the image subject.

Google finds images in the src attribute of an img element, even when it sits inside a picture element, but it does not index CSS background images, per Google's image SEO guide.

Place images near relevant text and on pages that match the subject. Google reads the captions, titles and surrounding text to understand what the image shows.

Add an image sitemap so Google can find images it might otherwise miss. Unlike regular sitemaps, an image sitemap can list URLs from other domains, so images hosted on a CDN still work.

You can also influence which image Google picks as the page preview by setting the og:image meta tag or the schema.org primaryImageOfPage property. Choose an image that is relevant and representative, avoid a generic logo or a text-heavy image, and avoid extreme aspect ratios, per Google's image SEO guide.

Reference the same image with the same URL on every page, so Google can cache and reuse it instead of requesting it again. The Open Graph protocol defines the og:image tag used for social and search previews, as documented at ogp.me.

How do you check that your image SEO is working?

Open Search Console, go to Performance, and filter by Search type to see image search traffic.

The image filter shows which queries bring clicks to your images and which pages they land on. If an image you expect to rank gets no impressions, check that the page is indexed and the image uses a normal img element.

Use the URL Inspection tool to see how Google renders the page, and PageSpeed Insights to check load time. Our page speed and SEO guide explains how speed feeds into search visibility.

If images fail to show at all, the cause is usually a broken file path, a missing file, or a plugin conflict. Our images not showing guide covers the checks in order.

What mistakes should you avoid?

The biggest mistake is uploading full-size camera photos straight into posts, which makes every page heavy for no reason.

  • Do not use CSS background images for content that should appear in search, since Google does not index them.
  • Do not skip alt text, and do not stuff it with keywords.
  • Do not lazy-load the hero image, since it sets the Largest Contentful Paint score.
  • Do not use one giant image for every screen size, or phones download desktop-sized files.
  • Do not hotlink images from other sites, since the file can vanish or change without warning.
  • Do not forget width and height attributes, or the page layout will shift as images load.

If an upload fails with an HTTP error, the file may be too large or in a format your host rejects. Our image upload error guide walks through the fixes.

Frequently asked questions

Does WordPress convert images to WebP automatically?

Yes, if you use an image optimizer plugin or serve WebP and AVIF with a JPEG fallback. WordPress does not convert images to modern formats by itself, so you need a plugin or an image CDN for the conversion. WordPress does generate responsive sizes and adds srcset automatically, which already cuts the bytes phones download.

What should I name my images and alt text for SEO?

Use a descriptive file name with dashes, such as red-running-shoes.jpg, and write alt text that describes the image, such as red running shoes on a white background. Keep both short and natural. The file name gives Google light clues about the subject, while alt text is the main signal it uses with the page content.

Should I lazy-load my hero image?

It depends on the image. A hero image at the top of a post is often the Largest Contentful Paint element, so it should load eagerly and be preloaded if possible. Images below the fold should lazy-load, which WordPress does by default. Check the rendered HTML to confirm the hero image has no loading=lazy attribute.

Does stuffing keywords into alt text help rankings?

No. Google says it uses alt text together with computer vision and the page content to understand the subject, so a few relevant words help. But stuffing the alt attribute with keywords creates a poor user experience and can look like spam. Write one clear description of what the image shows, and let the surrounding text carry the keywords.

Why are my images not showing up in Google Images?

Check three things. First, confirm the image uses a normal img element, not a CSS background, since Google does not index CSS images. Second, confirm the page itself is indexed. Third, add the image to an image sitemap and give it descriptive alt text and a file name. Then wait for Google to recrawl, which can take several days.

Sources

  1. Image SEO Best Practices Google Search Central
  2. Choose the right image format web.dev
  3. Optimize Largest Contentful Paint web.dev
  4. Responsive Images WordPress Developer Resources
  5. Lazy-loading images in 5.5 Make WordPress Core
  6. Enhanced lazy-loading performance in 5.9 Make WordPress Core
  7. wp_editor_set_quality WordPress Developer Resources

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

WPLegible editors

Researched from the primary sources listed above and checked against our editorial rules. About the site · How we test