-1

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

dnysaz
  • 1
  • 5

2 Answers2

1

You can't do it this way.

What you are trying to output, with your <?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!).

Gabriel
  • 1,401
  • 13
  • 21
0

You can not use image tag there. Instead, you should use

<meta property="og:image" content="<?php echo "http://$_SERVER[HTTP_HOST]/img/$image"; ?>" />
akshaypjoshi
  • 1,245
  • 1
  • 15
  • 24