AbanteCart Community

Shopping Cart Operations => Support => General Support => Topic started by: kelbel3abh on December 11, 2014, 08:58:30 PM

Title: What is the PHP for the product images?
Post by: kelbel3abh on December 11, 2014, 08:58:30 PM
Hey, there!  I am needing to know the php that will pick up the main product image on each product pages, so that Facebook knows which pic to use for social sharing. Right now, when someone shares to FB, it picks up random images on the page.

Here is what I am trying to put in the head.tpl

Here is what I need:
<meta property="og:image" content="url_of_image" />

I have tried both of these:
<meta property="og:image" content="<?php echo $image_url; ?>" />
<meta property="og:image" content="<?php echo $image['main_url']; ?>" />

However, when I view source, it shows up like this, so it isn't picking up code:
<meta property="og:image" content="" />
Title: Re: What is the PHP for the product images?
Post by: abantecart on December 12, 2014, 12:46:50 PM
Here is the controller for the product page:
https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/controller/pages/product/product.php

Head is processed by this controller
https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/controller/common/head.php

Check ADocument class to see how you can add to head from regular controller. You do not need to change head.php for this.
core/lib/document.php
Title: Re: What is the PHP for the product images?
Post by: Advisor on December 13, 2014, 10:38:14 PM
Thanks for clarifying...
Title: Re: What is the PHP for the product images?
Post by: kelbel3abh on December 18, 2014, 06:32:24 PM
Thanks for the reply, but I am confused.  I thought I could just put this in the head.tpl

<meta property="og:image" content="url_of_image" /> and I would just need the php to pick up the main product image.  No?
Title: Re: What is the PHP for the product images?
Post by: kelbel3abh on December 18, 2014, 06:38:23 PM
For instance, this url:

<meta property="og:image" content="<?php echo $image_url; ?>" />

But the <?php echo $image_url; ?> doesnt seem to work.
Title: Re: What is the PHP for the product images?
Post by: kelbel3abh on December 18, 2014, 07:08:51 PM
I also tried this one:
<meta property="og:image" content="<?php echo $image_main; ?>" />

When I view source, it just shows: <meta property="og:image" content="" />

So, I am using the wrong thing, I guess.  ??

Just to check, I used:
<meta property="og:image" content="<?php echo $base; ?>" />
and although that isn't what I need there, it did show up when I viewed the source code.
Title: Re: What is the PHP for the product images?
Post by: llegrand on December 18, 2014, 07:19:03 PM
have you looked at the new version of Sharethis extension.

It seems to do what you want - it's a free extension in the marketplace
http://marketplace.abantecart.com/sharethis (http://marketplace.abantecart.com/sharethis)

just be sure you install 1.0.2.

Title: Re: What is the PHP for the product images?
Post by: kelbel3abh on December 18, 2014, 09:30:34 PM
Hi, thanks!  I did try it a few days ago, but I see there is a new one.  I did have the same problem with that one not picking up the correct pic.  But, maybe now...

:) Will try it! -Kelly
Title: Re: What is the PHP for the product images?
Post by: kelbel3abh on December 18, 2014, 10:56:58 PM
This version does pick up the product images..yay!

I am just now trying to figure out how to change the text "Share to your Friends."  Anyone have an idea?
Title: Re: What is the PHP for the product images?
Post by: llegrand on December 18, 2014, 11:47:44 PM
Look in the System > Localizations > Language Definitions

then search the Key for

sharethis_share_text

There you can change it to whatever you would like.

Cheers,
Lee
Title: Re: What is the PHP for the product images?
Post by: kelbel3abh on December 19, 2014, 12:43:00 AM
Aha!  Thanks so much, Lee!
Title: Re: What is the PHP for the product images?
Post by: MehmoodAli on May 17, 2015, 08:02:26 AM
Lee
I can't find the Sharethis_share_text key in the path you told.


what seems to be the reason ?
Title: Re: What is the PHP for the product images?
Post by: llegrand on May 17, 2015, 09:06:55 AM
let me be sure you've gotten the correct version 
the Share_This extension works with version 1.1.9 and earlier of AbanteCart.   You seem to be new to the board so you maybe have the latest version which is 1.2.1.  That may be your issue.



FYI,  there will be a different "share"  for 1.2. versions available in the near future -  it will be Add-This. 

Lee




Title: Re: What is the PHP for the product images?
Post by: morrisr on April 17, 2016, 11:46:04 PM
Similar to links, I created an array metalinks and functions getmetalinks(), resetmetalinks() & addmetalink()
made the changes into:
document.php, head.php, head.tpl
I used  $this->document->addMetaLink(array('property' => 'og:type',  'content'  => 'product' )); in product.tpl and metalinks() values do not show on head.tpl ?