0

I have a travel site with a url like this one

http://www.mysite.tv/index.php?destination=somePlace

And when I share the url on Facebook, Telegram and Whatsapp I want to show an image for each destination.

For this in my index.php I have

<meta property="og:image" class="htmlImage" content="https://www.mysite.tv/img/img_<?php echo $_GET['destination'];?>.jpg" />

and in the img folder I have the appropriate image for each location.

The following happens:

To make it work on Facebook, I use the dynamic image but also a generic static image, although only the dynamic one is visible. This way:

<meta property="og:image" class="htmlImage" content="https://www.mysite.tv/img/img_<?php echo $_GET['destination'];?>.jpg" /> 
<meta property="og:image" class="htmlImage" content="https://www.mysite.tv/img/generic_image.jpg" />

also works for Telegram but this does not work for Whatsapp as it shows a cached static image.

And in Whatsapp only works a static image so I can not show an image for each of the destinations, only the generic static image.

<meta property="og:image" class="htmlImage" content="https://www.mysite.tv/img/generic_image.jpg" />

Is it possible to do some kind of programming to make it work on all three platforms?

If not possible, I mainly need it to work on Whatsapp, why doesn't a dynamic image work here, what can I do?

PS: please understand that it is not a problem of the image showing or not, I follow the design standards and static images always show without problems. It is a question of a dynamic image being displayed in the meta tags.

Thank you! !

1 Answer 1

0

Just in case somebody needs it, I have found the solution for me. Many many thanks to lcjr who posted it in the lazacode site.

Here it is:

<meta property="og:type" content="website"/>
<meta property="og:site_name" content="Edgeprop.my">
<meta property="og:url" content="<?php echo $ewfUrl; ?>" />
<meta itemprop="url" content="<?php echo $ewfUrl; ?>" />
<meta property="og:image" content="<?php echo $ewfImg; ?>" />
<meta itemprop="image" content="<?php echo $ewfImg; ?>" />
<meta name="image" content="<?php echo $ewfImg; ?>">
<meta name="twitter:image:src" content="<?php echo $ewfImg; ?>">
<meta property="og:title" content="<?php echo $ewfTitle; ?>" />
<meta name="twitter:title" content="<?php echo $ewfTitle; ?>">
<meta itemprop="name" content="<?php echo $ewfTitle; ?>">
<meta property="og:description" content="<?php echo $ewfDesc; ?>" />
<meta itemprop="description" content="<?php echo $ewfDesc; ?>">
<meta name="twitter:description" content="<?php echo $ewfDesc; ?>">
<meta name="description" content="<?php echo $ewfDesc; ?>">
<meta property="og:image:type" content="image/jpeg">
<meta property="og:image:alt" content="<?php echo $ewfDesc ?>" />