将css样式添加到og:image

将css样式添加到og:image,css,facebook-opengraph,Css,Facebook Opengraph,是否可以将CSS样式添加到用于facebook共享的facebook og:图像中?我没有使用静态图像,但它们是动态的(php) 所以,这是我的标签的当前状态,它只抓取特定产品的图像。但是,这只是一个图像。我想使用CSS在右上角放置一个彩色块,并在其中放置一些样式文本 <meta property="og:image" content="<?php echo $data['img_name']; ?>" /> 不,CSS是一种样式语言,不会直接应用于图像。调整此元标记时

是否可以将CSS样式添加到用于facebook共享的facebook og:图像中?我没有使用静态图像,但它们是动态的(php)

所以,这是我的标签的当前状态,它只抓取特定产品的图像。但是,这只是一个图像。我想使用CSS在右上角放置一个彩色块,并在其中放置一些样式文本

<meta property="og:image" content="<?php echo $data['img_name']; ?>" />

不,CSS是一种样式语言,不会直接应用于图像。调整此元标记时,它不会应用于实际图像

您可以做的是动态创建一个不同的图像,并在图像顶部添加一个新对象,并使用meta标记为该图像提供服务

<?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);
?>


源代码:

og:image
需要图像文件的路径,而只需要图像文件。如果要修改图像,则需要在将路径输出到标记之前完成此操作。