2
Answers
Vote up!
1
Vote down!

How do I to retrieve product image for product display og:image metatag?

I am using the metatag module and there is no problem to retrieve fields of the very node displayed. However, I cannot find how can I use the field_product_image of the product entity to use as a token for the Open Graph Protocol image attribute.

As I can use "regular" fields, I have added the issue here, and not in the metatag issue queue.

I have tried these toekns which I have found uner "Browse available tokens":
[node:field-product:1:field-product-image:?]
[node:field-product:1:field_product_image]

Also tried:
[node:field-product:1:field-product-image:0]
(referring to the first item in the array).

Any clue? Thanks!

Asked by: Amir Simantov
on May 12, 2013

2 Answers

Vote up!
1
Vote down!

How many products do you have on each node?

Field value deltas start at 0, which means if your display only has one product attached to it (or you have a single-value product reference field) then you should be using [node:field-product:0:field_product_image] instead of [node:field-product:1:field_product_image].

Poor UI, IMHO - it doesn't provide the 0th value in the available tokens dialog, but it works if you type it in.

For multiple-value image field metatags, there are a couple issues:

First, the Metatag module/submodules currently list all image urls in a comma-delineated list in a single meta tag. There is a fix for Open Graph tags at https://drupal.org/node/1305402#comment-6420040.

Second, selecting which image you want to use from a multiple-value field doesn't seem to be working currently. Same issue, later comment: https://drupal.org/node/1305402#comment-7890015

I'm also working on a sandbox module to expand the Metatag module to provide integration for Drupal Commerce/product-related tags, available at https://drupal.org/sandbox/rvallejo/2102725. I include the fix for splitting multiple images into multiple tags for Open Graph and Twitter, based on code at the first comment I linked to above.

Answer by: rvallejo
Posted: Oct 2, 2013
Vote up!
0
Vote down!

I have been battling this very same issue all night!

Answer by: Tom Brenner
Posted: May 28, 2013