Jump to content

Change og:picture to second product image


koyocik

Recommended Posts

Hi!

 

I'm trying to force socialsharing module, to use second, not first product image.

 

I've found here, thanks to Vekia some code to change in class Product.php:

 public static function geImagesByID($id_product, $limit = 2){
        $id_image = Db::getInstance()->ExecuteS('SELECT `id_image` FROM `'._DB_PREFIX_.'image` WHERE `id_product` = '.(int)($id_product) . ' ORDER BY position ASC LIMIT 1, ' . $limit);
        $toReturn = array();
        if(!$id_image)
           return;
        else
           foreach($id_image as $image)
              $toReturn[] = $id_product . '-' . $image['id_image'];
        return $toReturn;
    } 

but, have no idea what do next in socialsharing_header.tpl, I know it is here:

{if isset($link_rewrite) && isset($cover) && isset($cover.id_image)}
<meta property="og:image" content="{$link->getImageLink($link_rewrite, $cover.id_image, large_default)}" />
{/if}

Thanks.

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...