如何在 Twitter Card 中传递动态图像路径?

编程入门 行业动态 更新时间:2024-10-23 09:27:17
本文介绍了如何在 Twitter Card 中传递动态图像路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在使用

<?php $image='http://abc.in/def.jpg'; ?>
<html xmlns="http://www.w3/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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-29 15:49:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1192103.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路径   图像   动态   如何在   Card

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!