Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for image preview in WhatsApp #368

Open
Guite opened this issue Oct 25, 2019 · 0 comments
Open

Patch for image preview in WhatsApp #368

Guite opened this issue Oct 25, 2019 · 0 comments

Comments

@Guite
Copy link

Guite commented Oct 25, 2019

WhatsApp does only show a preview image (taken from og:image meta tag) if the shared text actually starts with the URL. Hence, I propose to swap url and title at https://github.com/heiseonline/shariff/blob/develop/src/js/services/whatsapp.js#L67

Currently I apply an ugly workaround to do it afterwards like this:

    if ($('li.shariff-button.whatsapp a').length > 0) {
        var shareStart = 'whatsapp://send?text=';
        var waBtn = $('li.shariff-button.whatsapp a').first();
        var linkParts = waBtn.attr('href').split('%20http');
        waBtn.attr('href', shareStart + 'http' + linkParts[1] + '%20' + linkParts[0].replace(shareStart, ''));
    }

As soon as this is included the image properly appears in WhatsApp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant