-
AutoOpenGraph?
Can anyone help with this AutoOpenGraph code that seems to appear in a few add ons? It appears to be the main part of the AutoFacebook OG add on, but while searching for help, I've found it referenced elsewhere, as well.
I'd like a simple way to get OpenGraph working on my site. This code might just work, except that, well, the main reason I'd like to install it is to get the appropriate product image to show up when someone decides to share a product URL to Facebook.
FB's Open Graph Object Debugger scrapes the product info well enough, but, unfortunately my main product image is too small for it. It wants a minimum 200px x 200px.
So, the AutoOpenGraph code that does this appears to be:
//get defined image or default
$myImage= zen_get_products_image((int)$_GET['products_id']);
$img = simplexml_load_string($myImage);
$img = $img['src'];
It looks to me like it's pulling the main image. Is there code that can be swapped in so that it would return the product image from the "large" images subdirectory? That might solve my problem.
Thanks!
-
Re: AutoOpenGraph?
So, one way to figure this out is to take a look at the code that returns the variable $myimage. If you goto http://www.zen-cart.com/docs/phpdoc-1-5-0/ you can navigate to the function and see how it builds the variable. If not mistaken it is an array, and sou would want to then modify the path of the image to obtain the large image path and possibly other characteristics of the image that are stored in the variable...
Also, could look at how the image informationis built in the tpl_product_info.php file and the header leading to it.
-
Re: AutoOpenGraph?
Just thought of this: (slow tonight), if uused Image Handler (version 4), the default image is the largest image and would be the ideal situation for you... No modification should be necessary... (I think).
-
Re: AutoOpenGraph?
I am indeed using Image Handler, but the code above is returning the main image, which is 120x156.
The main image, which the OG debugger finds, is images/subfolder/cover.jpg
I suspect it would prefer the large image at images/large/subfolder/cover_LRG.jpg
Thanks for the pointer to the phpdoc. I will investigate
-
Re: AutoOpenGraph?
Only done a cursory inspection, but it somewhat looks like you would want to change the call to a zen_image call instead of a zen_get_products_image call...
May require a little bit more upfront work similar to what is done in includes/modules/YOUR_TEMPLATE/main_product_image.php (modified by IH4) in obtaining the path to the products_image_large file... Once that path is designated, the response from zen_image should provide the image for the large version. Otherwise, the way it seems to read is that the small image will be returned as written above. Otherwise could provide dimensions to try to get a larger image, but I don't think that will provide the result(s) needed by the receiving application.
-
Re: AutoOpenGraph?
That's help! Thanks. I tried something with no luck. Looked in my debug logs and found these two lines just above the $myImage content:
extract($product_info_metatags->fields);
extract($category_metatags->fields);
were kicking back "extract() expects parameter 1 to be array, null given "
Maybe this was the problem all along
-
Re: AutoOpenGraph?
Here's the as it stand in MY_TEMPLATE/common/html_header.php
################ start of AutoOpenGraph ###################
$og_store_name = "NAME"; //e.g. "Samanthas Power Tools", or "Gus' China Shop".
$og_store_url = "SITE"; //url to your store (no trailing '/')
$og_product_type = "product"; //type of product you're selling (see tutorial)
$og_use_addr = 0; //use address? if yes, set $use_addr = 1; (no quotes). edit lines 31-34.
$og_use_email = 0; //use email address? if yes, set $use_email = 1; (no quotes) edit line 37.
$og_use_phone = 0; //use phone number? if yes, set $use_phone = 1; (no quotes) edit line 40.
//if $use_addr is set to 1;
$og_street = "123 Main St"; //change to your street address.
$og_city = "Richmond"; //your city
$og_state = "VA"; //Your State. Facebook exaple uses abbreviation.
$og_zip = "23220"; //you're zip/postal code.
$og_country = "USA"; //your country. Facebook example uses acronym.
//if $use_email is set to 1;
$og_email_address = "[email protected]"; // your email
//if use_phone is set to 1
$og_phone_number = "+1-800-555-1234"; //format: +country code - area code - number.
//no need to edit below this line:
extract($product_info_metatags->fields);
extract($category_metatags->fields);
$og_prod_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
//get defined image or default
//$myImage = zen_get_products_image((int)$_GET['products_id']);
$myImage = DIR_WS_IMAGES . 'large/' . $products_image_base . IMAGE_SUFFIX_LARGE . $products_image_extension;
$img = simplexml_load_string($myImage);
$img = $img['src'];
if($this_is_home_page){ $depends = $store_name; $product_type = "website"; }
else if ($categories_name){ $depends = $categories_name; $product_type = "website"; }
else if ($products_name){ $depends = $products_name; }
else { $depends = META_TAG_TITLE; $product_type = "website"; }
//print_r($product_info_metatags);
################# end of AutoOpenGraph ####################
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Content and Graphics Copyright (c) 2003 - 2026 Zen Ventures, LLC - all rights reserved
Zen Cart® is a Registered Trademark of Zen Ventures, LLC