ScreenshotNeo

BlogHow-to

How to Test an Open Graph Image

Check your Open Graph tags, verify that a social platform can fetch the image, and refresh LinkedIn’s cached preview when it is stale.

By the ScreenshotNeo team29 September 202610 min read

How to Test an Open Graph Image

To test an Open Graph image, inspect the page’s served HTML for og:image, open that image URL to confirm it returns the intended publicly accessible image, check the target platform’s image requirements, and use that platform’s preview tool to see what it actually fetched. For LinkedIn, its published sharing-module guidance specifies an image no larger than 5 MB, at least 1200 × 627 pixels, and a recommended 1.91:1 aspect ratio. These are LinkedIn specifications, not universal rules for every social platform.

A correct-looking page source does not prove that a social crawler can retrieve the image. Access controls, blocked requests, an incorrect canonical URL, or cached preview data can all make a share card differ from what you expect.

1. Understand which metadata controls the preview

The Open Graph Protocol defines four required properties: og:title, og:type, og:image, and og:url. The image property contains the URL of the preview image. Optional structured properties can provide its MIME type, width, height, secure URL, and alternative text. See the Open Graph Protocol specification.

A minimal set of tags in the document’s <head> might look like this:

<meta property="og:title" content="Example article title">
<meta property="og:type" content="article">
<meta property="og:url" content="https://example.com/articles/example">
<meta property="og:image" content="https://example.com/images/article-share.jpg">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="627">
<meta property="og:image:type" content="image/jpeg">
<meta property="og:image:alt" content="A description of the article image">

The example uses a public HTTPS URL and illustrative values. Replace them with the actual canonical page and image URLs and the image’s real properties. Do not claim dimensions in metadata that differ from the file.

Check the rendered HTML, not only your template

Templates, plugins, server rendering, and client-side scripts can affect the final document. View the page source or fetch the served HTML and search for og:image. Confirm there is a single intended primary image and that its value is an absolute URL. Multiple competing og:image tags can make it unclear which candidate a platform will select. If your site emits several images intentionally, inspect the destination platform’s actual preview rather than assuming which one it chooses.

Also compare og:url with the URL you share. A mismatch between a canonical page URL and a tracking or redirected URL can affect which page’s metadata is fetched or cached. Use the canonical URL your site intends visitors to share.

2. Verify the image URL itself

Copy the exact value of og:image into a browser address bar. Make sure it resolves to the intended image rather than a 404 page, login screen, HTML error, or an outdated file. Check the final destination after redirects. An image that loads for you while logged in may still be unavailable to a platform crawler.

Test the metadata, fetch the image directly, then confirm the platform’s own preview.
Test the metadata, fetch the image directly, then confirm the platform’s own preview.

For a quick command-line check, use cURL to inspect the response headers:

curl -L -I "https://example.com/images/article-share.jpg"

-I requests headers and -L follows redirects. Look for a successful response, an image content type such as image/jpeg or image/png, and an expected content length where the server provides one. A HEAD request can behave differently from a normal image download on some servers, so if its result is ambiguous, fetch the file:

curl -L "https://example.com/images/article-share.jpg" -o /tmp/article-share.jpg

Open the downloaded file and inspect its actual dimensions and file size with an image viewer or an image-inspection tool already available in your environment. Check that the URL does not require cookies, an authorization header, a signed-in session, or a short-lived signed link that will expire before the platform fetches it.

Confirm crawler access

For a social preview to appear, the destination platform must be able to retrieve the page metadata and the image. LinkedIn explicitly notes that an image can meet its requirements and still fail to appear when a site blocks its retrieval or the image is in a protected directory or website. See LinkedIn’s website sharing guidance.

Review access-control rules, CDN or firewall restrictions, hotlink protection, and any robots or bot-management settings that apply to the page and image paths. A URL that works in your browser is not enough if your browser sends credentials or your server treats automated requests differently. If access rules are the cause, make the intended image publicly retrievable under your site’s policy and retest with the platform inspector.

3. Compare the image with the platform’s requirements

Requirements depend on the destination and the kind of share preview. For LinkedIn’s sharing module, its help page specifies:

Check LinkedIn guidance What to verify
Maximum file size 5 MB Measure the actual image file, not the HTML response.
Minimum dimensions 1200 × 627 pixels Check the downloaded file’s pixel dimensions.
Recommended aspect ratio 1.91:1 Compare width divided by height; crop or export deliberately if needed.

These values come from LinkedIn Help. They do not guarantee a particular crop, display size, or result on another platform. If you are publishing to more than one destination, check each destination’s current official specifications rather than treating LinkedIn’s requirements as a shared standard.

Check visual composition as well as numbers. Important subjects or logos close to an edge may be cropped in a preview. If the image has transparency, confirm that it remains legible against the background likely to be used. Make sure the chosen image matches the page and that its alt text, if supplied, describes the image rather than repeating unrelated page copy.

4. Use LinkedIn Post Inspector to see the fetched preview

Metadata inspection tells you what your page publishes. LinkedIn’s Post Inspector shows the preview LinkedIn has fetched for a URL. To check it:

A corrected image may take time to appear because platforms cache preview data.
A corrected image may take time to appear because platforms cache preview data.
  1. Open LinkedIn Post Inspector.
  2. Enter the page URL you plan to share and run the inspection.
  3. Review the preview’s title, description, and image. Confirm the image is the intended asset and that the page shown corresponds to the URL you entered.
  4. If it is wrong, compare the inspected URL with your canonical URL, then revisit the page’s served Open Graph tags and image access.
  5. After making a correction, inspect again and use the refreshed preview for a new post.

LinkedIn says updates to shared URLs or their tags can take up to 48 hours to take effect. Its Post Inspector refreshes the preview used for future posts; it does not update the preview on existing posts. See LinkedIn’s URL-sharing troubleshooting guidance and Post Inspector instructions.

5. Automate basic checks with Python

A lightweight script can fetch a page and report the Open Graph properties present in its HTML. This checks the response your script receives; it does not emulate a platform crawler, prove that a platform can access the image, or replace the platform’s own inspector.

from html.parser import HTMLParser
from urllib.parse import urljoin
import requests

PAGE_URL = "https://example.com/articles/example"

class OpenGraphParser(HTMLParser):
    def __init__(self):
        super().__init__()
        self.tags = {}

    def handle_starttag(self, tag, attrs):
        if tag.lower() != "meta":
            return
        attrs = dict(attrs)
        prop = attrs.get("property", "").lower()
        if prop.startswith("og:"):
            self.tags.setdefault(prop, []).append(attrs.get("content", ""))

response = requests.get(PAGE_URL, timeout=20)
response.raise_for_status()
parser = OpenGraphParser()
parser.feed(response.text)

for name in ("og:title", "og:type", "og:image", "og:url"):
    values = parser.tags.get(name, [])
    print(f"{name}: {values or 'MISSING'}")

image_values = parser.tags.get("og:image", [])
if image_values:
    image_url = urljoin(PAGE_URL, image_values[0])
    image_response = requests.get(image_url, timeout=30, stream=True)
    print("image URL:", image_response.url)
    print("image status:", image_response.status_code)
    print("image content-type:", image_response.headers.get("content-type"))
    print("image content-length:", image_response.headers.get("content-length"))
    image_response.raise_for_status()
    image_response.close()

Install the dependency with python -m pip install requests. The script resolves a relative image URL against the page URL, follows normal redirects through Requests, and reports the final URL and response headers. It does not measure dimensions or fully download the image. Add those checks with an image library if your workflow needs automated dimension validation; keep platform-specific limits in configuration because they can differ and change.

6. Common errors and fixes

Symptom Likely cause Fix
No image appears The image URL returns an error, requires access, or is blocked to the crawler. Fetch the exact URL without a logged-in browser session, inspect redirects and response headers, and review protection rules.
The wrong image appears Another og:image candidate is present, the shared URL differs from the inspected URL, or the platform has cached an older result. Check all served tags and canonical URLs, then run the platform inspector on the exact share URL.
The image is rejected or omitted It exceeds a destination’s limit, has unsuitable dimensions, or is not served as a valid image. Check the actual downloaded file against that platform’s published rules and verify its response content type.
Browser works but inspector does not Your browser has cookies or credentials, or a firewall, CDN, bot rule, or hotlink policy blocks automated retrieval. Test unauthenticated access and adjust the relevant access rule for the intended public asset.
Changes do not show immediately The platform is using cached preview data. Use its refresh workflow and allow for its documented propagation time. For LinkedIn, allow up to 48 hours; existing posts retain their old preview.
Script reports missing tags The server returned a different page, tags are injected only after JavaScript runs, or the request was redirected. Check the response status and final page URL, then inspect the served source. Ensure important metadata is present in the HTML available to crawlers.

7. Performance, reliability, and cost

Manual source and URL checks are quick for one page. For a large site, automate presence checks and image response checks during publishing, while leaving final verification to the destination platform’s own inspector. Store the page URL, image URL, response status, content type, file size, and measured dimensions with the check result. Avoid treating a successful HTTP response as proof that every platform can fetch the image: crawler access and preview selection still need to be checked at the destination.

Keep tests bounded with request timeouts, follow redirects deliberately, and avoid repeatedly downloading large assets when headers or a cached local copy are enough for routine checks. Do not infer an image’s dimensions from metadata; inspect the bytes when validating dimensions. Recheck after changing page templates, CDN rules, image paths, or metadata plugins, since any of those can alter what the platform receives.

The DIY workflow uses ordinary HTTP requests and the platform’s preview tooling. Its cost is primarily development and operational time; no third-party screenshot service is required to inspect metadata. If you need a visual screenshot of a live page as part of a broader QA workflow, choose a capture method that fits the checks you need, and do not confuse a browser screenshot of the page with a social platform’s fetched share preview.

Or skip the browser setup

To capture a page visually with ScreenshotNeo, make one request to its screenshot API. The API can return a clean PNG, JPEG, WebP, or PDF. See the ScreenshotNeo API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/articles/example -o shot.webp
import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://example.com/articles/example"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({
  access_key: 'YOUR_API_KEY',
  url: 'https://example.com/articles/example'
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
await Bun.write('shot.webp', new Uint8Array(await res.arrayBuffer()));

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots, and the free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. A screenshot can help you review the rendered page, but use LinkedIn Post Inspector to verify the preview LinkedIn fetched. Learn more at ScreenshotNeo, or sign up for 1,000 free screenshots a month, with no card.

FAQ

Does an og:image tag guarantee that image will appear?

No. The platform must be able to retrieve the image and accept it for the share preview. Check the fetched preview with the destination’s own tool.

Do LinkedIn’s image requirements apply to every social platform?

No. The 5 MB maximum, minimum 1200 × 627 pixels, and recommended 1.91:1 ratio cited here are LinkedIn sharing-module guidance. Confirm other platforms’ current requirements from their own documentation.

Will refreshing a LinkedIn URL update an existing post?

No. LinkedIn says Post Inspector refreshes the preview used for future posts; existing posts keep their old preview.

Should I put image dimensions in the Open Graph tags?

The protocol supports structured width and height properties. If you include them, make them match the actual image file and still verify the file itself.