How to Optimize Images for SEO: The Complete Guide

Image SEO is one of the most underused levers in on-page optimisation. Most sites obsess over title tags and meta descriptions while leaving hundreds of unoptimised images sitting on every page — slowing load times, bleeding crawl budget, and missing out on Google Image Search traffic. This guide covers everything: alt text, file naming, dimensions, compression, modern formats, lazy loading, responsive images, image sitemaps, CDNs, structured data, and ecommerce-specific tactics. Follow the checklist at the end and you will have covered every major image optimisation signal that matters for SEO in 2026.

Quick audit: Before reading on, run a free RankNibbler site audit on your page. It checks alt text, lazy loading, dimensions, and 30+ other SEO signals in seconds.

Why Image Optimization Matters for SEO

Images affect SEO in more ways than most people realise. Here is why image SEO deserves serious attention:

In short, image optimization is not a niche technical task — it sits at the intersection of performance, accessibility, and content quality, all of which influence rankings directly or indirectly.

Consider some concrete numbers. According to HTTP Archive data, images account for around 50% of the total page weight of an average webpage. Google's PageSpeed Insights and Lighthouse audits list image-related recommendations — such as "Serve images in next-gen formats", "Properly size images", and "Efficiently encode images" — among the most common opportunities identified. For many sites, fixing images alone is enough to move from a failing Core Web Vitals score to a passing one. That is a ranking improvement available entirely without touching a single line of content or acquiring a single backlink.

1. Alt Text: The Complete Guide

Alt text (the alt attribute on an <img> tag) serves three purposes: it tells search engines what the image shows, it is read aloud by screen readers for visually impaired users, and it is displayed when the image fails to load. Getting alt text right is the most important single step in image SEO.

How to Write Good Alt Text

10+ Alt Text Examples

ContextPoor Alt TextGood Alt Text
Running shoe productshoeRed Nike Air Zoom Pegasus 41 running shoe, side view
SEO dashboard screenshotimageRankNibbler SEO score dashboard showing 92 out of 100
Recipe photocake.jpgChocolate fudge cake with vanilla cream frosting on white plate
Office team phototeamFive-person marketing team in a glass-walled conference room
InfographicinfographicInfographic showing 5-step image SEO optimisation process
Chart or graphchartBar chart comparing WebP versus JPEG file size reduction percentages
Blog hero imageheroPerson typing on laptop with SEO analytics on screen
LogologoRankNibbler logo
Decorative borderborder imagealt="" (empty — skip it)
Icon buttoniconSearch icon or aria-label if the icon is inside a button
Property listinghouseThree-bedroom terraced house with red brick exterior in Manchester
Before/after comparisonbeforeWebsite homepage before redesign with cluttered navigation

You can audit every image on your page for missing or thin alt text using the RankNibbler alt text checker. It flags empty alt attributes, very short alt text, and alt text that matches the file name (a common sign of auto-generated placeholder text).

2. Image File Naming

Search engines read file names as a signal when indexing images. A file called IMG_4521.jpg tells Google nothing. A file called red-nike-air-zoom-pegasus-running-shoe.jpg reinforces the image content and can help it rank in image search for relevant queries.

File Naming Best Practices

File Naming Examples

Bad File NameGood File Name
IMG_4521.jpgred-nike-running-shoe-side-view.jpg
DSC00342.pnglondon-bridge-at-sunset.png
screenshot1.webpranknibbler-seo-score-dashboard.webp
product_photo.jpgoak-dining-table-180cm-walnut.jpg
image (1).jpgchocolate-fudge-cake-recipe.jpg

3. Image Dimensions and Aspect Ratios

Always declare explicit width and height attributes on every <img> tag. This is one of the easiest fixes in image SEO and it has a direct impact on Core Web Vitals.

Why Dimensions Matter

When a browser starts rendering a page, it builds the layout before all images have finished loading. If the browser does not know how tall and wide an image will be, it cannot reserve space for it. When the image eventually loads, the page shifts — that is Cumulative Layout Shift (CLS). A CLS score above 0.1 is considered poor by Google and can negatively affect rankings.

Adding width and height attributes gives the browser the information it needs to reserve the exact right amount of space before the image loads, eliminating layout shift entirely.

Correct HTML Example

<img src="red-nike-running-shoe.webp" alt="Red Nike Air Zoom running shoe" width="800" height="600">

With CSS, you can still make images responsive while keeping the aspect ratio hint:

img { max-width: 100%; height: auto; }

The browser uses the declared width and height to calculate the aspect ratio and reserve space, even when CSS changes the rendered size.

Common Display Sizes and Aspect Ratios

Use CaseRecommended DimensionsAspect Ratio
Blog hero / featured image1200 × 630px1.91:1
Open Graph image (social share)1200 × 630px1.91:1
Product image (square)800 × 800px1:1
Product image (portrait)800 × 1000px4:5
Full-width content image1200 × 800px3:2
Thumbnail400 × 300px4:3
Logo200 × 60px (or SVG)Variable
Twitter Card large image1200 × 628px1.91:1

Use the RankNibbler image dimensions checker to audit your pages for images with missing width and height attributes.

4. Image Compression Techniques and Tools

Compression is where the biggest performance gains come from. An uncompressed 3MB hero image can become a 90KB WebP file with no visible quality difference at normal screen sizes. That is a 97% reduction in file size and a dramatic improvement in load time.

Lossy vs Lossless Compression

Target File Sizes

Image TypeTarget File SizeNotes
Hero / banner (WebP)Under 150KBCritical for LCP score
Product photo (WebP)Under 100KBEspecially important on listing pages
Blog content image (WebP)Under 80KBMultiple images per page add up
Thumbnail (WebP)Under 30KBCan appear dozens of times on a page
Logo (SVG)Under 10KBSVG scales perfectly at any size

Compression Tools

Resolution Matters Too

Uploading a 4000-pixel-wide photograph to a site where it displays at 800px wide is wasteful. The browser downloads four times more data than it needs. Always resize images to roughly the maximum rendered size before applying compression. For responsive images, see the srcset section below.

5. Modern Image Formats: WebP and AVIF

Choosing the right format is as important as compression settings. JPEG and PNG were designed in the 1990s. WebP and AVIF are modern formats engineered for the web, offering significantly better compression at the same visual quality.

Format Comparison

FormatBest ForTypical Size Saving vs JPEGBrowser SupportTransparency
AVIFPhotos, all general use50% smallerChrome, Firefox, Safari 16+, EdgeYes
WebPPhotos and graphics25–35% smallerAll modern browsers (99%+ global)Yes
JPEGPhotos (fallback)BaselineUniversalNo
PNGGraphics with hard edgesLarger than JPEG for photosUniversalYes
SVGIcons, logos, illustrationsScales infinitelyUniversalYes
GIFSimple animations (use video instead)Much larger than MP4UniversalBasic (1-bit)

Recommended Strategy

Serve AVIF to browsers that support it, WebP as the fallback, and JPEG/PNG as the last resort. Use the HTML <picture> element to declare multiple sources:

<picture>
  <source srcset="image.avif" type="image/avif">
  <source srcset="image.webp" type="image/webp">
  <img src="image.jpg" alt="Descriptive alt text" width="800" height="600">
</picture>

The browser picks the first format it supports. If you use an image CDN (like Cloudflare Images or imgix), format negotiation happens automatically via the Accept HTTP header — you do not need to manage multiple files.

What About GIFs?

Avoid GIFs for animations. An animated GIF is typically 5 to 20 times larger than the equivalent MP4 video. Use a <video> element with autoplay, loop, muted, and playsinline attributes instead. It looks identical to users but loads far faster.

6. Lazy Loading Images

Lazy loading defers the loading of images that are not yet visible in the viewport. Instead of downloading every image on the page when it first loads, the browser only fetches images as the user scrolls toward them. This reduces the initial page load time and saves bandwidth for users who never scroll past the fold.

How to Implement Lazy Loading

The native browser API requires just one attribute:

<img src="below-fold-image.webp" alt="Chart showing SEO traffic growth" width="800" height="450" loading="lazy">

Browser support for loading="lazy" is now universal across modern browsers. No JavaScript library is needed.

What Not to Lazy Load

Never add loading="lazy" to images that are visible above the fold on initial page load — especially:

Lazy loading these images will delay them and actively hurt your LCP score, which is a Core Web Vitals ranking factor. Add loading="eager" (or simply omit the attribute) for above-the-fold images. For your most critical hero image, consider adding fetchpriority="high" as well:

<img src="hero.webp" alt="Homepage hero image" width="1200" height="630" fetchpriority="high">

Use the RankNibbler lazy loading checker to audit your pages and identify images that should have loading="lazy" and any above-the-fold images that have been incorrectly lazy-loaded.

7. Responsive Images with srcset

A single image file served to all devices wastes bandwidth on mobile phones, which do not need a 1400-pixel-wide image to fill a 390-pixel screen. The srcset attribute lets you provide multiple image files at different sizes and let the browser pick the most appropriate one based on the device's screen size and pixel density.

srcset Syntax

<img
  src="image-800.webp"
  srcset="image-400.webp 400w, image-800.webp 800w, image-1200.webp 1200w"
  sizes="(max-width: 600px) 100vw, (max-width: 900px) 80vw, 800px"
  alt="Image SEO guide header"
  width="800" height="450"
>

The srcset attribute declares available image files and their widths. The sizes attribute tells the browser how wide the image will be rendered at different viewport sizes. The browser then downloads the smallest file that still looks sharp on the user's screen. On a mobile device with a 390px viewport, it might download the 400w version. On a Retina display, it might choose the 800w or 1200w version.

Pixel Density Descriptors

For simpler cases like logos and icons, you can use pixel density descriptors (1x, 2x) instead of width descriptors:

<img src="logo.webp" srcset="logo.webp 1x, [email protected] 2x" alt="RankNibbler logo" width="160" height="48">

Automating Responsive Images

Generating multiple size variants of every image manually is tedious. Image CDNs and build tools handle this automatically. Next.js has a built-in Image component that generates srcset automatically. WordPress generates multiple sizes on upload. Cloudinary and imgix can resize on-the-fly based on URL parameters.

8. Image Sitemaps

An image sitemap (or image data within your main sitemap) tells Google about images on your site that it might not discover through normal crawling — particularly images loaded by JavaScript or embedded in CSS backgrounds.

How to Add Images to Your XML Sitemap

You can embed image data directly in your existing XML sitemap using the image: namespace:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
  <url>
    <loc>https://www.example.com/product/running-shoe</loc>
    <image:image>
      <image:loc>https://www.example.com/images/red-nike-running-shoe.webp</image:loc>
      <image:title>Red Nike Air Zoom Pegasus Running Shoe</image:title>
      <image:caption>Red Nike Air Zoom Pegasus 41 in crimson and white</image:caption>
    </image:image>
  </url>
</urlset>

Image Sitemap Tips

You can generate and check your overall sitemap structure from the RankNibbler site audit.

9. Image CDNs

An image CDN (Content Delivery Network) is a specialised service that stores, transforms, and delivers images from servers close to your users. Unlike a general CDN which simply caches static files, an image CDN can resize, reformat, and compress images on-the-fly based on the requesting device.

Key Benefits of Image CDNs

Popular Image CDN Options

ServiceNotesFree Tier
Cloudflare Images$5/month flat rate, tight Cloudflare integrationNo (paid only)
CloudinaryFull-featured, generous free tier, widely usedYes (25GB)
imgixPowerful URL-based transforms, used by large sitesTrial only
Bunny.net OptimizerAffordable, good WebP/AVIF supportYes (limited)
Next.js Image OptimizationBuilt-in, handles srcset and format automaticallyYes (self-hosted)

For most sites, the combination of Cloudflare CDN (for caching) plus Squoosh or Sharp for pre-processing is sufficient. Image CDNs become worth it once you have thousands of images or complex multi-device requirements.

10. Image Structured Data

Structured data (JSON-LD schema markup) can make your images eligible for rich results in Google Search. Adding ImageObject schema or embedding image data within Article, Product, or Recipe schema can result in your images appearing prominently in search results with additional context.

ImageObject Schema

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "ImageObject",
  "url": "https://www.example.com/images/red-nike-running-shoe.webp",
  "width": 800,
  "height": 600,
  "name": "Red Nike Air Zoom Pegasus Running Shoe",
  "description": "Red Nike Air Zoom Pegasus 41 running shoe, side view on white background",
  "contentUrl": "https://www.example.com/images/red-nike-running-shoe.webp"
}
</script>

Images Within Other Schema Types

Google requires images in structured data to be crawlable and indexable (not blocked by robots.txt or requiring authentication). The image URL in your schema should match the actual URL used in your HTML.

11. Ecommerce Image SEO

Ecommerce sites have unique image SEO challenges. A typical product catalogue might contain tens of thousands of images, often auto-generated by a CMS with generic file names and missing or templated alt text. Getting image SEO right at scale requires a systematic approach.

Product Image Best Practices

Category Page Image Optimisation

Category pages often load 20, 40, or even 100 product thumbnail images. Each one is a potential image search result and each one contributes to page load time. Use lazy loading on all product thumbnails except the first two rows, and compress thumbnails to the smallest reasonable file size. A 300×300 WebP thumbnail should be under 30KB in most cases.

Image SEO for Google Shopping

Google Shopping (both paid and free product listings) uses the product images you provide in your Google Merchant Center feed. The feed pulls images from your Product schema or your data feed file. Requirements for Shopping images are stricter than for organic image search: no watermarks, no promotional overlays, no placeholders, and white or light grey backgrounds are strongly preferred for apparel and hard goods. Images must be at least 100×100px (250×250px for clothing) and no larger than 64MB. Larger images with more detail perform better in Shopping results because Google can display them at higher resolution in the product panel. Aim for 800×800px or larger as your primary product image.

Handling Image Variants

Many ecommerce products come in multiple colours or configurations. The SEO-friendly approach is to provide a distinct image for each variant and update the displayed image via JavaScript when the user selects a colour, without changing the page URL. Ensure the canonical product page shows at least one high-quality image in its HTML (not rendered exclusively via JavaScript after user interaction), so Googlebot can index it without needing to interact with the page. For products with many variants, an image sitemap that lists all variant image URLs under the canonical product URL helps ensure full image indexation.

12. Common Image SEO Mistakes

Even experienced SEOs make these mistakes consistently. Run a full site audit to catch them systematically.

Mistakes That Hurt Page Speed

Mistakes That Hurt SEO Signals

Mistakes That Hurt User Experience

Testing and Measuring Image SEO Performance

Optimising images is not a one-time task. Images are added continuously through blog posts, product uploads, and CMS content, and each new image is an opportunity to get it right or wrong. Build testing into your publishing workflow.

Set a reminder to re-audit your highest-traffic pages every quarter. As your CMS adds images and plugins change how assets are served, image SEO can regress even without any deliberate changes.

Image SEO Checklist

Use this checklist for every page you publish or audit. You can also run the RankNibbler homepage checker or the full site audit to automate many of these checks.

#CheckTool
1Every content image has descriptive alt text (not empty, not keyword-stuffed)Alt Text Checker
2Decorative images use alt=""Manual review
3All image file names are descriptive (hyphens, lowercase, no generic names)Manual review
4Every <img> tag has explicit width and height attributesDimensions Checker
5Below-fold images have loading="lazy"Lazy Loading Checker
6Hero / above-fold images do NOT have loading="lazy"Lazy Loading Checker
7Critical hero image has fetchpriority="high"Manual review
8Images are compressed to target file sizesSquoosh / TinyPNG
9Images are served in WebP (or AVIF) formatRankNibbler Audit
10<picture> tags or CDN provide JPEG/PNG fallbacks for older browsersManual review
11srcset and sizes attributes used for responsive imagesManual review
12Images are included in XML sitemap with title and captionGoogle Search Console
13Images are NOT blocked in robots.txtSite Audit
14Images are served over HTTPS (no mixed content)Site Audit
15Product pages include Product schema with image propertyManual review
16No broken image URLs returning 404Site Audit
17CLS score is 0.1 or below (images not causing layout shift)CLS Guide
18Page load time is acceptable (images not a major bottleneck)Page Speed Guide

Frequently Asked Questions About Image SEO

Does alt text directly affect Google rankings?

Yes, indirectly and directly. Alt text is one of the primary signals Google uses to understand what an image shows and therefore what topic a page covers. It directly influences image search rankings. It also feeds into the overall topical relevance signals for the page. Missing alt text on key images means leaving ranking signals on the table.

How important is image file name for SEO?

It is a moderate signal. Google confirms that it uses file names as one of many signals to understand image content. It is not as strong as alt text, but it takes seconds to do correctly and there is no reason to skip it. Rename images before uploading — changing a live URL later requires a redirect and can affect any image search traffic the URL has accumulated.

Should I use WebP or AVIF?

Use both, with AVIF as the preferred format and WebP as the fallback. AVIF offers better compression (typically 20-30% smaller than WebP at the same quality), but WebP has wider browser support. Use a <picture> element to serve AVIF first, WebP second, and JPEG/PNG as the final fallback. If you use an image CDN, it handles this automatically.

Does image file size affect rankings?

Not directly, but it affects page speed, which does. Google's page speed signals — particularly Core Web Vitals like LCP — are direct ranking factors. Large image files that slow down LCP will hurt rankings. So while Google does not look at a 500KB image and penalise it, the knock-on effect on page speed and user experience does affect your position.

What is the best image size for SEO?

There is no single best size — it depends on how the image is used. The key principle is to match the upload resolution to the maximum rendered size. A blog content image displayed at 800px wide should be uploaded at 800–1200px wide (to cover 2x Retina screens), compressed in WebP to under 100KB. See the dimensions table above for common use cases.

How do I get my images to appear in Google Image Search?

Ensure images have descriptive alt text, descriptive file names, and are not blocked by robots.txt. Add image data to your XML sitemap and submit it via Google Search Console. Use high-quality, original images (stock photos shared across thousands of sites are less likely to rank). Surround images with relevant text that provides context. Check indexing status in Google Search Console under the Coverage report.

Should I lazy load all images?

No. Only lazy load images that are not visible in the viewport on initial page load (below the fold). Never lazy load your hero image, logo, or any other image in the first viewport. Incorrectly lazy-loading above-fold images is one of the most common causes of a poor LCP score. Use the lazy loading checker to audit your pages.

What does fetchpriority="high" do?

The fetchpriority attribute hints to the browser that a specific resource should be downloaded with high priority. Adding fetchpriority="high" to your hero or LCP image tells the browser to start downloading it as soon as possible, before it has fully parsed the rest of the page. This can meaningfully improve LCP scores on pages with a large above-fold image.

Do image CDNs help SEO?

Yes, indirectly. Image CDNs improve page speed by serving optimally sized and formatted images from edge locations close to users. Faster pages score better on Core Web Vitals, which are ranking factors. They also eliminate the need to manually maintain multiple image format variants. For sites with large image libraries, an image CDN is often the most practical way to implement image optimisation at scale.

How do I check if my images are indexed by Google?

Use Google Search Console. Go to Coverage and filter by image type, or use the URL Inspection tool on specific image URLs. You can also search Google Images for your site using site:yourdomain.com within Google Images search. If you have a large site, the image sitemap report in Search Console will show how many image URLs have been submitted and indexed.

Does Google care about image format?

Google can index all common image formats including JPEG, PNG, WebP, AVIF, SVG, and GIF. It does not penalise you for using JPEG over WebP. However, the format choice affects file size, which affects page speed, which affects rankings. Use modern formats like WebP and AVIF to keep file sizes small and page speed scores high.

What alt text should I use for buttons and icons?

If the icon or button has a visible text label alongside it, the image should use alt="" (empty) to avoid reading it out twice to screen reader users. If the icon IS the only label for a button (for example, a magnifying glass icon with no text label), use descriptive alt text like alt="Search". Alternatively, use aria-label on the button element itself and mark the image as decorative with alt="".

Automate your image audit: The RankNibbler homepage checker analyses alt text, lazy loading, and image dimensions on any URL. The site audit crawls your entire site and reports image issues across every page. Both are free.

Last updated: April 2026