This question has been flagged

Hello all,

On our shop product page (example : http://intimeetvilain.com/shop/product/lubrifiant-pure-4-onces-901 ), we have this code in the template :

<t t-if="main_object and 'image' in main_object">
    <meta property='og:image' t-att-content="request.httprequest.host_url+website.image_url(product, 'image')" />
</t>

With this code we always had the right product image when we put a product page url on facebook.

But since we also have a « suggested product » section at the bottom of the product page, the image is never the right one on Facebook. Our code always take image of THE LAST product in the « suggested products » section.

How could we correct this and take always an only image from the main product in the og:image tag?


 

Avatar
Discard
Author Best Answer

A new miracle!

Here is the solution :

     <t t-if="main_object and 'image' in main_object">
        <meta property='og:image' t-att-content="request.httprequest.host_url+website.image_url(product[0], 'image')" />
    </t>

This way, the image in og:image facebook tag is always the image of the main product and not the image of one of the « suggested products ».


Avatar
Discard