0

I am using one php echo to add a meta tag og:image as follows:

1

echo "<meta property=\"og:image\" content=\"https://example.com/Gallery/$b/$new/imagename-$b-$new-$three.jpg\" />";

and echos this image url: https://example.com/Gallery/book/new/imagename-book-new-3.jpg

2

And I started using phpThumb to resize the image dimensions in the url parameters (as I didnt find an easiter way), and the echo is:

echo '<img src="'.htmlspecialchars(phpThumbURL('src=https://example.com/Gallery/book/new/imagename-book-new-3.jpg&w=100&h=200', '/phpThumb/phpThumb.php')).'">';

What I need to do is merge the 2 echo (without img src part) inside the first!

I tried a lot, and what I want is something like:

Result

echo "<meta property=\"og:image\" content=\"'.htmlspecialchars(phpThumbURL('src=https://example.com/Gallery/$b/$new/imagename-$b-$new-$three.jpg&w=100&h=200&iar=1', '/zJ/phpThumb/phpThumb.php')).'\" />";
Mike
  • 2,051
  • 4
  • 28
  • 46
  • Why doesn't your last snippet work as desired? Ah, change single quotes to double quotes. – mickmackusa Jan 17 '19 at 02:30
  • It is PHP. Maybe preg_replace_callback, I am new to this and couldn't try it. If possible edit it as you see right and post it. – Mike Jan 17 '19 at 02:30

1 Answers1

0

Change single quotes to double quotes so that the middle concatenated portion is executed (not printed as a static string).

echo "<meta property=\"og:image\" content=\""
     . htmlspecialchars(phpThumbURL("src=https://example.com/Gallery/$b/$new/imagename-$b-$new-$three.jpg&w=100&h=200&iar=1", '/zJ/phpThumb/phpThumb.php'))
     . "\" />";
mickmackusa
  • 43,625
  • 12
  • 83
  • 136
  • Still not working, it gives an error "Failed to load resource: the server responded with a status of 500 ()" and doesn't load the page. – Mike Jan 17 '19 at 02:38
  • Whoops, need to change the quotes on the first parameter of `phpThumbURL()` too because it contains variables. – mickmackusa Jan 17 '19 at 02:42