I Have a litle bit problem with meta tag image script.
I already try like this :
<meta property="og:image" content="<?php echo "<img src='/img/$image'>"; ?>" />
is that possible ? thank you
You can't do it this way.
What you are trying to output, with your <?php echo "<img src='...'>"; ?>
<?php echo "<img src='...'>"; ?>
is a full HTML tag.
But, you output this string inside the value of an attribute (namely, attribute content
) of a tag ( <meta>
).
This value must be a string, and I believe that you simply need to print there the absolute URL of the image (not the full <img>
tag!).
You can not use image tag there. Instead, you should use
<meta property="og:image" content="<?php echo "http://$_SERVER[HTTP_HOST]/img/$image"; ?>" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.