如何在 Twitter Card 中传递动态图像路径? [英] How to pass dynamic image path in Twitter Card?

查看:42
本文介绍了如何在 Twitter Card 中传递动态图像路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

<?php $image='http://abc.in/def.jpg'; ?>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta name="twitter:card" content="summary">
        <meta name="og:image" content="<?php echo $image?>">
        <meta name="og:description" content="<?php echo $description; ?>">
        <meta name="og:title" content="<?php echo $title; ?>">
        <meta name="twitter:url" content="http://keyss.in">
        <meta name="twitter:app:id:iphone" content="">
        <meta name="twitter:app:id:ipad" content="">
        <meta name="twitter:app:id:googleplay" content="">
        <meta name="twitter:app:url:iphone" content="">
        <meta name="twitter:app:url:ipad" content="">
        <meta name="twitter:app:url:googleplay" content="">
    </head>
</html>

我的 Twitter 帖子的代码.

code for my Twitter post.

当我在 中传递静态内容时图像张贴在我的 Twitter 墙上,但如果我将变量作为<meta name="og:image" content="<?php echo $image?>">图片没有贴在我的墙上.

When I pass static content in <meta name="og:image" content="http://abc.in/def.jpg"> image is posted on my Twitter wall, but if I pass variable as <meta name="og:image" content="<?php echo $image?>"> image is not posted on my wall.

如何在图像内容中传递动态变量?

How can I pass dynamic variable in image content?

推荐答案

$image 后缺少分号可能是问题所在(如评论中所述):

The missing semicolon after $image could be the issue (as mentioned in the comments):

    <meta name="og:image" content="<?php echo $image; ?>">
    <meta name="og:description" content="<?php echo $description; ?>">
    <meta name="og:title" content="<?php echo $title; ?>">

修复代码后,通过 Twitter 卡验证器运行页面以确保一切都正确显示.希望它能让您了解发生了什么问题.

Once you've fixed the code, run the Page through the Twitter Card validator to make sure everything appears correctly. It should hopefully give you an idea of what's going wrong.

这篇关于如何在 Twitter Card 中传递动态图像路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆