News:

AbanteCart v1.4.2 is released.

Main Menu
support

What is the PHP for the product images?

Started by kelbel3abh, December 11, 2014, 08:58:30 PM

Previous topic - Next topic

kelbel3abh

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="" />

abantecart

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

Advisor


kelbel3abh

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?

kelbel3abh

For instance, this url:

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

But the <?php echo $image_url; ?> doesnt seem to work.

kelbel3abh

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.

llegrand

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.


kelbel3abh

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

kelbel3abh

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?

llegrand

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

kelbel3abh


MehmoodAli

Lee
I can't find the Sharethis_share_text key in the path you told.


what seems to be the reason ?

llegrand

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





morrisr

Quote from: abantecart on December 12, 2014, 12:46:50 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 ?

Forum Rules Code of conduct
AbanteCart.com 2010 -