Skip to content

Link preview image is generated too small when using WhatsApp User-Agent #344

Description

@claytim

Link preview image is generated too small when using WhatsApp User-Agent

After fixing the preview fetching issue for bot-protected websites such as Mercado Livre by setting a WhatsApp-like User-Agent, the link preview is now being generated correctly.

However, the preview image is being sent in a small size.

When the same image/link is sent manually through WhatsApp, the preview image appears large, as expected. But when sent through WuzAPI, the preview image appears much smaller.

Current behavior

The link preview image is displayed in a small size.

Expected behavior

The preview image should be displayed in the same large format as when the link is sent manually through WhatsApp.

Context

The previous issue was related to websites returning 403 when using Go's default Go-http-client User-Agent. This was fixed by setting headers such as:

req.Header.Set("User-Agent", "WhatsApp/2.23.20.0")
req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8")
req.Header.Set("Accept-Language", "pt-BR,pt;q=0.9,en;q=0.8")

The preview is now fetched, but the image size/format does not match WhatsApp’s native behavior.

Example:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions