css - 将 css 样式添加到 og: image
问题描述
是否可以将 CSS 样式添加到您将用于 Facebook 共享的 facebook og:image?我没有使用静态图像,但它们是动态的(php)
所以,这是我当前状态的标签,它只是抓取该特定产品的图像。但是,它只是一个图像。例如,我想使用 CSS 在右上角放置一个彩色块,并在其中放置一些样式文本。
<meta property="og:image" content="<?php echo $data['img_name']; ?>" />
我对 Facebook 分享不是很熟悉,所以不确定这是否可能。
解决方案
不,CSS 是一种样式语言,不会直接应用于图像。调整此元标记时,它不会应用于实际图像。
您可以做的是动态制作不同的图像并在图像顶部添加一个新对象并使用元标记提供此图像。
<?php
// Load the stamp and the photo to apply the watermark to
$stamp = imagecreatefrompng('stamp.png');
$im = imagecreatefromjpeg('photo.jpeg');
// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);
// Copy the stamp image onto our photo using the margin offsets and the photo
// width to calculate positioning of the stamp.
imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));
// Output and free memory
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
推荐阅读
- leaflet - 如何获取传单 WMS 地图的最近特征?
- php - WebP 后备图像未加载
- matlab - 根据颜色图更改现有绘图线
- javascript - Google Script - 将文件名的一部分与子文件夹名称进行比较,如果匹配则将文件移动到子文件夹
- php - 合并子数组 (PHP 5.3.3)
- accelerometer - IMU 跌倒检测
- javascript - 我在 javascript 中的循环代码给出了“内存不足”错误
- django - 如何在 django 中保存时将模型与当前用户关联
- html5-canvas - 弹跳球代码导致 HTML5 画布中的抖动
- apache - Apache HTTP TimeOut 指令的最大可能值是多少?