mercredi 19 août 2015

How to Let Facebook Share Recognise Random Background Image

my problem is, I am generating my background images per CSS and PHP on my web site http://goo.gl/VDtmbk like this:

CSS:

background: url(random_img.php) no-repeat top left fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; background-attachment: fixed;

PHP, random_img.php:

header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header('Content-Type: image/jpeg');
$vorresult = glob( "../../uploads/*1500x*.jpg" );
$result = array_diff( $vorresult, glob( "../../uploads/*{person,karte}*.jpg", GLOB_BRACE ) );
$seed = floor(time()/120); 
srand($seed); 
$random_image = $result[rand(0, count($result)-1)];
header('Location:'.$random_image.'');

I read somewhere: Facebook should find images on one's web site with no problem, as long as they appear directly in the html (as ) and not via css (background-image: url(path/to/img.png);).

So, is there a way to solve this, so Facebook Sharing "sees" the random background image (to have it then in the shared post on FB)?




Aucun commentaire:

Enregistrer un commentaire