Answer the question
In order to leave comments, you need to log in
How to make different images for og:image meta tag via php?
Online cinema. The site has 3 additional fields for images, and you need them to be displayed in meta tags.
Briefly about additional fields
poster - the field where the poster is loaded from the computer to the site server
poster-link - a link to the poster from another server
screens - a wide poster for social. networks and messengers, for example, for instagram, vk, viber, telegram.
screens is only used in TV shows.
In show.full.php I did
$social_tags['image'] = "/uploads/posts/" . $xfieldsdata['poster'];
$social_tags['image'] = $xfieldsdata['poster-link'];
$social_tags['image'] = $xfieldsdata['screens'];
<meta property="og:image" content="x">
<meta property="og:image" content="">
Answer the question
In order to leave comments, you need to log in
$social_tags['image'] = $xfieldsdata['screens']
?? $xfieldsdata['poster-link']
?? ( $xfieldsdata['poster'] ? "/uploads/posts/".$xfieldsdata['poster'] : '/link/to/default.jpg' );
It's very helpful to read the documentation.
Check for emptiness - https://www.php.net/manual/ru/function.empty.php
String length - https://www.php.net/manual/ru/function.mb-strlen.php
IF construct. ..ELSE...ELSEIF - https://www.w3schools.com/php/php_if_else.asp
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question