简体   繁体   中英

facebook post images from php url

i have a mysql table where i store all the images uploaded by users (in a blob column).

To show the images on my website I use a simple script, like this:

  $res = mysql_query("SELECT image FROM table WHERE id=$id");
  $row = mysql_fetch_assoc($res);
  header("Content-type: image/jpeg");
  echo $row['dvdimage'];

and then i call the image with: < img src="script.php?id=1" />

Everything works fine in my website, the image is shown, but when I share the link or post the image on facebook the thumbnail of the image is not visible...

I don't understand if the error is mine (for example I just have to add some headers in the script.php file, or i can use htaccess to resolve the problem)

...or if the blob/php is a bad practice to store the images in this case..

When you share a link on Facebook it crawl the url and fetch data. You can check here what data is Facebook getting from your url.

To tell Facebook what information to show using og tags. Adding headers are not enough to Facebook to detect content.

Check here to get more info about open graph protocol.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM