我的音乐评论应用程序有一个图片(即专辑封面)与每个评论(称为“Pins”)相关联。以前,在分享评论到Facebook时,专辑封面会显示为缩略图。现在根本没有图片显示。
当我使用facebook调试器时,我得到以下信息:
og:image未定义,无法下载或不够大。请使用og:image元标记定义所选图像,并使用至少为200x200px并可从Facebook访问的图像。将使用图像'http://s3.amazonaws.com/theTens/pins/images/000/000/150/medium/arcade-fire-reflektor-cover-500x500_(1).jpg?1387660087'代替。
我明白我需要设置类似于这样的元标记:
当我使用facebook调试器时,我得到以下信息:
og:image未定义,无法下载或不够大。请使用og:image元标记定义所选图像,并使用至少为200x200px并可从Facebook访问的图像。将使用图像'http://s3.amazonaws.com/theTens/pins/images/000/000/150/medium/arcade-fire-reflektor-cover-500x500_(1).jpg?1387660087'代替。
我明白我需要设置类似于这样的元标记:
<meta property="og:image" content='http://s3.amazonaws.com/theTens/pins/images/000/000/150/medium/arcade-fire-reflektor-cover-500x500_(1).jpg?1387660087'/>
如何设置元标记以根据用户分享的页面动态获取图像URL?
该图像使用Paperclip上传,然后托管在Amazon S3上。
编辑:Prakash在下面给出了正确的答案,因此这里是我在应用程序助手中编写的帮助器方法。(我还必须设置url_path)
def og_image_path
if @pin.present?
@pin.image.url
end
end
def og_url_path
if @pin.present?
"http://www.thetens.us/pins/" + @pin.to_param
end
end
我的头部中的元标签:
<meta property="og:image" content="<%= og_image_path %>">
<meta property="og:url" content="<%= og_url_path %>">
<meta property="og:title" content="Album Review">
<meta property="og:description" content="The Music Review Site Where YOUR Opinion Matters">