Please help us to make AbanteCart Ideal Open Source Ecommerce Solution for everyone.

Support AbanteCart eCommerce

Author Topic: What is the PHP for the product images?  (Read 8903 times)

Offline kelbel3abh

  • Newbie
  • *
  • Posts: 42
  • Karma: +5/-0
    • View Profile
What is the PHP for the product images?
« 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="" />

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4358
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: What is the PHP for the product images?
« Reply #1 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
Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

Offline Advisor

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +7/-4
    • View Profile
Re: What is the PHP for the product images?
« Reply #2 on: December 13, 2014, 10:38:14 PM »
Thanks for clarifying...

Offline kelbel3abh

  • Newbie
  • *
  • Posts: 42
  • Karma: +5/-0
    • View Profile
Re: What is the PHP for the product images?
« Reply #3 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?

Offline kelbel3abh

  • Newbie
  • *
  • Posts: 42
  • Karma: +5/-0
    • View Profile
Re: What is the PHP for the product images?
« Reply #4 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.

Offline kelbel3abh

  • Newbie
  • *
  • Posts: 42
  • Karma: +5/-0
    • View Profile
Re: What is the PHP for the product images?
« Reply #5 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.

Offline llegrand

  • Hero Member
  • *****
  • Posts: 1798
  • Karma: +520/-7
    • View Profile
Re: What is the PHP for the product images?
« Reply #6 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

just be sure you install 1.0.2.


Offline kelbel3abh

  • Newbie
  • *
  • Posts: 42
  • Karma: +5/-0
    • View Profile
Re: What is the PHP for the product images?
« Reply #7 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

Offline kelbel3abh

  • Newbie
  • *
  • Posts: 42
  • Karma: +5/-0
    • View Profile
Re: What is the PHP for the product images?
« Reply #8 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?

Offline llegrand

  • Hero Member
  • *****
  • Posts: 1798
  • Karma: +520/-7
    • View Profile
Re: What is the PHP for the product images?
« Reply #9 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

Offline kelbel3abh

  • Newbie
  • *
  • Posts: 42
  • Karma: +5/-0
    • View Profile
Re: What is the PHP for the product images?
« Reply #10 on: December 19, 2014, 12:43:00 AM »
Aha!  Thanks so much, Lee!

Offline MehmoodAli

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: What is the PHP for the product images?
« Reply #11 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 ?

Offline llegrand

  • Hero Member
  • *****
  • Posts: 1798
  • Karma: +520/-7
    • View Profile
Re: What is the PHP for the product images?
« Reply #12 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





Offline morrisr

  • Newbie
  • *
  • Posts: 9
  • Karma: +4/-0
  • Simple is good
    • View Profile
    • Aloha Elegant
Re: What is the PHP for the product images?
« Reply #13 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 ?

 

Powered by SMFPacks Social Login Mod