Skip to content

/send/link only produces a small link preview — high-res thumbnail (MediaLinkThumbnail) is not uploaded #103

Description

@abgpt

Welcome!

  • Yes, I have searched for similar issues on GitHub and found none.

What did you do?

I sent a message through POST /send/link with a real URL and an OG image, expecting the big rich link-preview card you get when a normal user pastes a link into WhatsApp. The imgUrl is populated (or auto-fetched from the page metadata).

Roughly this body:

{
  "number": "<group>@g.us",
  "text": "…summary text… https://example.com/trail",
  "url": "https://example.com/trail",
  "title": "",
  "description": "",
  "imgUrl": "https://example.com/image-1200x630.jpg"
}

What did you expect?

A large link-preview card — the OG image rendered big at the top of the message, tapping through to the URL.

It reproduces every time. The image loads fine, so this is specifically about the large-vs-small render path (the missing MediaLinkThumbnail upload), not the image failing to show.

What did you observe instead of what you expected?

Only the small preview shows up: a little thumbnail on the left side, no matter how large the OG image is. So it works, it's just always the small variant.

The image itself embeds fine — I checked the outgoing message and it carries the full 1200×630 image as a ~297 KB JPEGThumbnail. WhatsApp just renders it small.

The reason is in sendLinkWithRetry (pkg/sendMessage/service/send_service.go, around lines 754–762). The ExtendedTextMessage is built with only the inline thumbnail:

previewType := waE2E.ExtendedTextMessage_VIDEO
msg := &waE2E.Message{
    ExtendedTextMessage: &waE2E.ExtendedTextMessage{
        Text:          &data.Text, 
        Title:         &data.Title,
        MatchedText:   &matchedText,
        JPEGThumbnail: fileData,   
        Description:   &data.Description,
        PreviewType:   &previewType,
    },
}

Two things stand out. First, it never uploads a high-res link thumbnail, so ThumbnailDirectPath, ThumbnailSHA256, ThumbnailEncSHA256, ThumbnailWidth and ThumbnailHeight are all unset — and those fields (plus the MediaHandle on send) are exactly what WhatsApp needs to render the large card. An inline JPEGThumbnail on its own always renders small, at any resolution. Second, PreviewType is hardcoded to VIDEO for what are image links, even though the enum has a dedicated IMAGE (5).

Screenshots/Videos

No response

Which version are you using?

0.7.1

What is your environment?

Docker

If applicable, paste the log output

Here's the outgoing message (trimmed) from a POST /send/link call:

Info.Type: "ExtendedTextMessage"   
Message.extendedTextMessage:
  matchedText:   "https://example.com/trail"
  title:         "…"
  description:   "…"
  previewType:   1                 # VIDEO
  JPEGThumbnail: <~297 KB, 1200×630 jpeg>
  # thumbnailDirectPath / thumbnailSha256 / thumbnailEncSha256 /
  # thumbnailWidth / thumbnailHeight  — all absent
  # no MediaHandle passed on send  

Additional Notes

Suggested Fix:

Happy to Contribute.

The gist is to upload the fetched image as a link thumbnail and wire the returned fields onto the message:

up, err := client.Upload(ctx, fileData, whatsmeow.MediaLinkThumbnail)
// then on the ExtendedTextMessage:
//   ThumbnailDirectPath  = &up.DirectPath
//   ThumbnailSHA256      = up.FileSHA256
//   ThumbnailEncSHA256   = up.FileEncSHA256
//   ThumbnailWidth/Height = <decoded dims>
//   JpegThumbnail        = <small ~100px jpeg>   // keep for the fallback
//   PreviewType          = IMAGE  

…and pass the upload handle through on send:

client.SendMessage(ctx, jid, msg, whatsmeow.SendRequestExtra{ MediaHandle: up.Handle })

This will probably mean threading SendRequestExtra.MediaHandle through the internal SendMessage wrapper, which doesn't currently expose it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions