Preview checker: a page that only has `og:image:url` is reported as having no image

Offen Anfängerfreundlich
#455 2 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

@MugdhoAI arbeitet bereits daran.

Seit 04.12.2026.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
88/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
web-dev

Rechercherichtung

Beginne mit parseMetaTags in src/lib/meta-fetcher.ts, überprüfe dann resolveUrl und die vorhandenen Fälle in tests/lib/meta-fetcher.test.ts. Führe die fokussierte Testdatei aus und verwende npm run dev mit /preview, um den fehlenden Bildbericht zu reproduzieren. Fertig ist, wenn og:image:url wie angegeben behandelt wird, das bestehende Verhalten unverändert bleibt und npm run check, npm run test sowie npm run build erfolgreich durchlaufen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug good first issue

parseMetaTags only takes the image from og:image (src/lib/meta-fetcher.ts lines 72 and 89). The Open Graph docs define og:image:url as identical to og:image, so a page can use it as its only image tag:

<meta property="og:image:url" content="/card.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">

The checker doesn't see an image there, and it drops the width and height too, since they only count after an og:image. I ran parseMetaTags and analyzeMeta on a page where everything else is set, once with each tag:

og:image      → https://example.com/card.png, 1200 wide, score 100 (A)
og:image:url  → no image, no width, score 70 (C)
                "Missing og:image tag ..."
                "No twitter:image or og:image ..."

The platform previews use the same value, so they have no Open Graph image to show for that page either.

What to do

  • In parseMetaTags, use og:image:url when the page has no og:image with content. An easy way is to decide before the loop which of the two starts an image group, then use that one everywhere the loop checks for og:image now.
  • It goes through resolveUrl like og:image does, the first one with content wins, and the width and height after it belong to it.
  • When the page has an og:image with content, ignore og:image:url, whichever comes first. It must not start a new group, or the width and height after it would be lost.
  • og:image:secure_url isn't part of this one.
  • Add tests to tests/lib/meta-fetcher.test.ts.

Acceptance criteria

  • The example above gives the absolute image URL, 1200 and 630, and neither of the two missing image errors
  • With both tags, og:image is used in either order, and its width and height are kept when og:image:url sits between them
  • An empty og:image next to an og:image:url with content uses og:image:url
  • With several og:image:url tags, the first one with content is used, with its own width and height
  • Pages without og:image:url come out exactly as before
  • A test that fails on the current code
  • npm run check, npm run test and npm run build pass

How to test
Run the new tests, then npm run dev, open /preview and check a page whose only image tag is og:image:url. The report should list the image, and the previews should show it.


Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #455 in the description.

Vorherrschende Sprache
TypeScript
Sterne
8
Forks
4
Ø Merge
1 T. 21 Std.
Gemergte PRs (30 T.)
34

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus codercops/ogcops

Alle Issues in codercops/ogcops

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.