2

I would like to populate my meta tags, specifically Facebook Open Graph meta with the current entry's data. Most of it straight forward but am struggling with grabbing the image url.

The image field is a Simple S3 Uploader field

<head>
{exp:channel:entries dynamic="no" disable="categories|category_fields|member_data|pagination"}
<meta property="og:title" content="{title}">
<meta property="og:description" content="{intro}">
<meta property="og:type" content="article")
<meta property="og:url" content="{site_url}{if segment_1 != ''}/{segment_1}{/if}{if segment_2 != ''}/{segment_2}{/if}{if segment_3 != ''}/{segment_3}{/if}{if segment_4 != ''}/{segment_4}{/if}">
<meta property="og:image" content="**http://www.your-site.com/image.jpg"**>
<meta property="og:site_name" content="{site_name}">
<meta property="fb:admins" content="your-Facebook-page-user-ID">
{/exp:channel:entries}
</head>
1
  • Where is this above code located? Inside of your channel:entries loop in your entry view template? Or inside an embed? Commented Aug 29, 2013 at 19:00

1 Answer 1

2

Since the Simple S3 Uploader is a normal fieldtype, you simply use the field name for the image field like:

<meta property="og:image" content="{custom_field_name}">

You can look at the documentation for additional tags that are available with the fieldtype.

5
  • it's returning blank. am getting this in the html: <meta property="og:image" content="">. Actually, even things like title,it seem to be returning the same thing for all the entries, it's the last entry in the system.
    – Abs
    Commented Aug 29, 2013 at 18:36
  • You should examine the parameters of your channel:entries tag. You have dynamic set to no, yet you're not feeding it an entry_id or url_title. So, I'm not surprised that it's not pulling the correct entry. Commented Aug 29, 2013 at 18:56
  • Pulling in the right entry but still struggling with the image field. This how my images are set up: Field is called "images" which is a matrix field, the matrix column where images uploaded is called "file" which is an Simple S3 Uploader. In og:image meta tag set like this: <meta property="og:image" content="{images}{file}{/images}">.However, am getting all the images in the matrix and it's prefixed with http:// like this <meta property="og:image" content="images.s3.amazonaws.com/134556783-4-Wendy-image-Ints-.jpghttp://…">
    – Abs
    Commented Aug 29, 2013 at 19:47
  • I have changed it to: {images}<meta property="og:image" content="{file}">{/images} so now I have multiple Og:image tags but the urls aren't compelete
    – Abs
    Commented Aug 29, 2013 at 19:54
  • sorry ignore my comment, all working fine :)
    – Abs
    Commented Aug 29, 2013 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.