【发布时间】:2015-08-19 12:45:28
【问题描述】:
我的问题是,我在我的网站http://goo.gl/VDtmbk 上按 CSS 和 PHP 生成背景图像,如下所示:
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.'');
我在某处读到:Facebook 应该可以毫无问题地在自己的网站上找到图像,只要它们直接出现在 html 中(如 <img src="path/to/img.png" />)而不是通过 css(background-image: url(path/to/img.png);)。
那么,有没有办法解决这个问题,让 Facebook 分享“看到”随机背景图片(然后将其放在 FB 上的共享帖子中)?
【问题讨论】:
标签: php facebook random background-image share