I have installed the Metatag module on a Drupal Commerce site, with the intention to make the OpenGraph metatag of the product image available to Facebook. The idea is that Facebook picks the image of an article based on the metag.
However I don't see what token to use to construct the metatag field 'image'.

An example image URL to the article image is: http://example.com/sites/default/files/styles/scalecrop_450x450/public/a...

In the Metatag settings, I try to add the image metatag to the product display content type.

I can see that this token is available [node:field-product:0:field-images:file] But if I append that to the URL http://example.com/sites/default/files/styles/scalecrop_450x450/public/ ..then Facebook does not pick it up. I use the Sharing Debugger of Facebook to test it, and clear the cache and scrape each time.

How to construct the URL that should go in the OpenGraph metatag 'image' ?

CommentFileSizeAuthor
#3 metatags image.jpg11.74 KBYuri
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Yuri created an issue. See original summary.

DamienMcKenna’s picture

Try using just "[node:field-product:0:field-images]" and see how it works.

Yuri’s picture

FileSize
11.74 KB

I tried [node:field-product:0:field-images] but that is not working.
It appears that Metatag just does not recognize tokens at all? I see that this is an issue often posted.
The Metatag module shows the following in admin/config/search/metatags#

metatag for image

DamienMcKenna’s picture

@Yuri: Yes, Metatag supports tokens, to say otherwise is just silly. Metatag does not control the token browser, that's the Token module's responsibility. Nested tokens are a little fiddly to deal with, I'll see if I can get some time soon to test it out.

GuyPaddock’s picture

@DamienMcKenna: Tokens support for product images does, indeed, seem broken.

Using this token [node:field-product:0:field-product-image] (we're using a different field name for the product images), this is what the markup looks like:

<meta property="og:image" content="http://URL-TO-MY-SITE/Property%200" />
<meta property="og:image" content="http://URL-TO-MY-SITE/Property%201" />
GuyPaddock’s picture

Okay, so... this variant seems to work:
[node:field-product:0:field_product_image]

Note the underscores instead of the hyphens. As always, the usability of the Token module is at an all-time high.

MikeiLL’s picture

I'm relatively new to Drupal and have been struggling with this issue for a couple of hours now.

Using Drupal 7 and Metatag 7.x-1.22.

I have added a Default Meta Tag: Content Product.

I have tried putting tokens as well as url strings into:

  • Advanced Tags > image
  • Open Graph > image
  • Open Graph > image url

I have tried the following nodes and "available tokens":

  • [node:uc-product-image]
  • [node:field-product:0:field_product_image]
  • [metatag:image_source]

The following tags are being generated, but I cannot seem to get the "og:image" tag to generate.

  • property="fb:admins"
  • property="fb:app_id"
  • property="og:site_name"
  • property="og:type"
  • property="og:title"
  • property="og:url"
  • property="og:description"
  • property="og:updated_time"
  • name="twitter:card"
  • name="twitter:title"
  • name="twitter:url"
  • name="twitter:description"

What on earth am I missing?

DamienMcKenna’s picture

@MikeiLL: What is the name of the field that you want to use? What type of field is it?

MikeiLL’s picture

@DamienMcKenna Thank you so much for getting back to me.

I am not sure what type of field it is: a "Product Image"? It gets added via an Image, File Upload form at `example.com/node/843`.

The images display in `example.com/sites/default/files/`. It resides in an HTML block that looks like this:

<div class="gallery-frame">
 <ul>
  <li class="gallery-slide" id="slide-0-uc_product_image-843" style="display: block;">
   <img class="image-style-none" src="https://www.example.com/sites/default/files/coffee_loo_table.jpg" width="816" height="612" alt="" title="TAB-043 coffee height loo table image 1"></li>
  <li class="gallery-slide" id="slide-1-uc_product_image-843" style="display: none;">
    <img class="image-style-none" src="https://www.example.com/sites/default/files/detail_burl.jpg" width="816" height="612" alt="" title="TAB-043 coffee height loo table image 2">
  </li>
 </ul>
</div>

Does that help? I'm used to Wordpress, but with Drupal very much in the dark. Not sure how one can actually "inspect" nodes.

DamienMcKenna’s picture

@MikeiLL: Go to the content types admin list (admin/structure/types), click on the "manage fields" link for the content type you're working on, find the "machine name" for the image field and let us know what it is.

As for inspecting nodes, you can use the Devel module to give you a "Devel" tab on the node page that gives you a nested array display of the node's values. But I don't think you need that right now.

MikeiLL’s picture

Product (Machine name: product)
Use products to represent items for sale on the website, including all the unique information that can be attributed to a specific model number.

DamienMcKenna’s picture

@MikeiLL: Oh, I see. Are you using Commerce Kickstart v2?

MikeiLL’s picture

Commerce is actually installed, but disabled. We are using Ubercart (as far as I can tell).

DamienMcKenna’s picture

Component: Open Graph » Documentation
Category: Support request » Task

Ok, that would change how the tokens would be used.

Because this issue is focused on Commerce, I opened another issue for working with Ubercart: #3031096: Tokens for Ubercart product images

Let's move over to the other issue.