Thread: AutoOpenGraph?

Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18
  1. #11
    Join Date
    Jan 2004
    Posts
    144
    Plugin Contributions
    0

    Default Re: AutoOpenGraph?

    Hmm. The large image does exist at images/large/subfolder/cover_LRG.jpg

    Unsure of what to do next.

  2. #12
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: AutoOpenGraph?

    Quote Originally Posted by Randolph Hoppe View Post
    Hmm. The large image does exist at images/large/subfolder/cover_LRG.jpg

    Unsure of what to do next.
    What does your code look like in the area of:
    Code:
    $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){
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #13
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: AutoOpenGraph?

    This is what I see as a potential solution based on information provided thus far (untested), but it seems like it addresses the possibility of image handler being installed and to obtain the path associated:

    Code:
    $og_prod_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    
    //get defined image or default
    //$myImage = zen_get_products_image((int)$_GET['products_id']);
    
    $products_id = (int)$_GET['products_id'];
    
    if (zen_not_null($products_id) && $products_id !== 0) {
    
    $sql = "select p.products_image from " . TABLE_PRODUCTS . " p where products_id= :product_id:";
    $sql = $db->bindVars($sql, ':product_id:', $products_id, 'integer');
    $look_up = $db->Execute($sql);
    
    
     $products_image = DIR_WS_IMAGES . $look_up->fields['products_image'];
    $products_image_extension = substr($products_image, strrpos($products_image, '.'));
    $products_image_base = preg_replace('/' . $products_image_extension . '$/', '', $products_image);
    $products_image_large = DIR_WS_IMAGES . 'large/' . $products_image_base . IMAGE_SUFFIX_LARGE . $products_image_extension;
    
    
    $myImage = zen_image($products_image_large, zen_get_products_name($products_id), LARGE_IMAGE_WIDTH, LARGE_IMAGE_HEIGHT)
    
    //$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){
    I could be wrong... :)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #14
    Join Date
    Jan 2004
    Posts
    144
    Plugin Contributions
    0

    Default Re: AutoOpenGraph?

    Quote Originally Posted by mc12345678 View Post
    What does your code look like in the area of:
    Code:
    $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){
    Right now, it looks like this:

    Code:
    $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){

  5. #15
    Join Date
    Jan 2004
    Posts
    144
    Plugin Contributions
    0

    Default Re: AutoOpenGraph?

    Thanks, MC!

    I pasted in this (added a semi-colon at the end of the $myImage line. Was I correct?):
    Code:
    $og_prod_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    
    //get defined image or default
    //$myImage = zen_get_products_image((int)$_GET['products_id']);
    
    $products_id = (int)$_GET['products_id'];
    
    if (zen_not_null($products_id) && $products_id !== 0) {
    
    $sql = "select p.products_image from " . TABLE_PRODUCTS . " p where products_id= :product_id:";
    $sql = $db->bindVars($sql, ':product_id:', $products_id, 'integer');
    $look_up = $db->Execute($sql);
    
    
    $products_image = DIR_WS_IMAGES . $look_up->fields['products_image'];
    $products_image_extension = substr($products_image, strrpos($products_image, '.'));
    $products_image_base = preg_replace('/' . $products_image_extension . '$/', '', $products_image);
    $products_image_large = DIR_WS_IMAGES . 'large/' . $products_image_base . IMAGE_SUFFIX_LARGE . $products_image_extension;
    
    
    $myImage = zen_image($products_image_large, zen_get_products_name($products_id), LARGE_IMAGE_WIDTH, LARGE_IMAGE_HEIGHT);
    
    //$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) {
    Now, the Facebook Open Graph Scraper/Debugger is not finding an image file. It's saying the image name is basically the domain.com..

  6. #16
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: AutoOpenGraph?

    Quote Originally Posted by Randolph Hoppe View Post
    Thanks, MC!

    I pasted in this (added a semi-colon at the end of the $myImage line. Was I correct?):
    Code:
    $og_prod_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    
    //get defined image or default
    //$myImage = zen_get_products_image((int)$_GET['products_id']);
    
    $products_id = (int)$_GET['products_id'];
    
    if (zen_not_null($products_id) && $products_id !== 0) {
    
    $sql = "select p.products_image from " . TABLE_PRODUCTS . " p where products_id= :product_id:";
    $sql = $db->bindVars($sql, ':product_id:', $products_id, 'integer');
    $look_up = $db->Execute($sql);
    
    
    $products_image = DIR_WS_IMAGES . $look_up->fields['products_image'];
    $products_image_extension = substr($products_image, strrpos($products_image, '.'));
    $products_image_base = preg_replace('/' . $products_image_extension . '$/', '', $products_image);
    $products_image_large = DIR_WS_IMAGES . 'large/' . $products_image_base . IMAGE_SUFFIX_LARGE . $products_image_extension;
    
    
    $myImage = zen_image($products_image_large, zen_get_products_name($products_id), LARGE_IMAGE_WIDTH, LARGE_IMAGE_HEIGHT);
    
    //$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) {
    Now, the Facebook Open Graph Scraper/Debugger is not finding an image file. It's saying the image name is basically the domain.com..
    Try removing the if statement as commented below... I may have chosen the wrong test values... If it works, still recommend incorporating something to ensure that it doesn't permit other nasties.. :)

    I'm wondering if as a result of that if statement that none of the code is being run based on the content of the "error" being the site's base url. If there is more text that might be applicable, that would be good to know about to properly capture the correct information and code.

    Code:
    $og_prod_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    
    //get defined image or default
    //$myImage = zen_get_products_image((int)$_GET['products_id']);
    
    $products_id = (int)$_GET['products_id'];
    
    /* if (zen_not_null($products_id) && $products_id !== 0) */ {
    
    $sql = "select p.products_image from " . TABLE_PRODUCTS . " p where products_id= :product_id:";
    $sql = $db->bindVars($sql, ':product_id:', $products_id, 'integer');
    $look_up = $db->Execute($sql);
    
    
    $products_image = DIR_WS_IMAGES . $look_up->fields['products_image'];
    $products_image_extension = substr($products_image, strrpos($products_image, '.'));
    $products_image_base = preg_replace('/' . $products_image_extension . '$/', '', $products_image);
    $products_image_large = DIR_WS_IMAGES . 'large/' . $products_image_base . IMAGE_SUFFIX_LARGE . $products_image_extension;
    
    
    $myImage = zen_image($products_image_large, zen_get_products_name($products_id), LARGE_IMAGE_WIDTH, LARGE_IMAGE_HEIGHT);
    
    //$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) {
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #17
    Join Date
    Jan 2004
    Posts
    144
    Plugin Contributions
    0

    Default Re: AutoOpenGraph?

    It's still not finding what it needs. Here's more code-y context, if it helps:

    Code:
    <?php
    /**
     * Common Template
     *
     * outputs the html header. i,e, everything that comes before the \</head\> tag <br />
     *
     * @package templateSystem
     * @copyright Copyright 2003-2012 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version GIT: $Id: Author: DrByte  Tue Jul 17 16:02:00 2012 -0400 Modified in v1.5.1 $
     */
    /**
     * load the module for generating page meta-tags
     */
    require(DIR_WS_MODULES . zen_get_module_directory('meta_tags.php'));
    /**
     * output main page HEAD tag and related headers/meta-tags, etc
     */
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" <?php echo HTML_PARAMS; ?>>
    <head>
    <title><?php echo META_TAG_TITLE; ?></title>
    
    <?php
    ################ start of AutoOpenGraph ###################
     
    $og_store_name = "Store Name"; //e.g. "Samanthas Power Tools", or "Gus' China Shop".
    $og_store_url = "http://domain.tld"; //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"; //your 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']);
    
    $products_id = (int)$_GET['products_id'];
    
    /* if (zen_not_null($products_id) && $products_id !== 0) */ {
    
    $sql = "select p.products_image from " . TABLE_PRODUCTS . " p where products_id= :product_id:";
    $sql = $db->bindVars($sql, ':product_id:', $products_id, 'integer');
    $look_up = $db->Execute($sql);
    
    
    $products_image = DIR_WS_IMAGES . $look_up->fields['products_image'];
    $products_image_extension = substr($products_image, strrpos($products_image, '.'));
    $products_image_base = preg_replace('/' . $products_image_extension . '$/', '', $products_image);
    $products_image_large = DIR_WS_IMAGES . 'large/' . $products_image_base . IMAGE_SUFFIX_LARGE . $products_image_extension;
    
    
    $myImage = zen_image($products_image_large, zen_get_products_name($products_id), LARGE_IMAGE_WIDTH, LARGE_IMAGE_HEIGHT);
    
    //$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 = $products_name; }
    else { $depends = META_TAG_TITLE; $product_type = "website"; }
    //print_r($product_info_metatags);
    ################# end of AutoOpenGraph ####################
     
    ?>
    <!-- start of AutoOpenGraph tags -->
    <meta property="og:title" content="<?php echo $depends; ?>" />
    <meta property="og:type" content="<?php echo $og_product_type; ?>" />
    <meta property="og:url" content="<?php echo $og_prod_url; ?>" />
    <meta property="og:image" content="<?php echo $og_store_url . '/' . $img; ?>" />
    <meta property="og:description" content="<?php echo META_TAG_DESCRIPTION; ?>" />
    <meta property="og:site_name" content="<?php echo $og_store_name; ?>" />
    <?php
    if($use_addr){
    echo '<meta property="og:street-address" content="'.$og_street.'" />'."\n";
    echo '<meta property="og:locality" content="'.$og_city.'" />'."\n";
    echo '<meta property="og:region" content="'.$og_state.'" />'."\n";
    echo '<meta property="og:postal-code" content="'.$og_zip.'" />'."\n";
    echo '<meta property="og:country-name" content="'.$og_country.'" />'."\n";
    }
    if($use_email){
    echo '<meta property="og:email" content="'.$og_email_address.'" />'."\n";
    }
    if($use_phone){
    echo '<meta property="og:phone_number" content="'.$og_phone_number.'" />'."\n";
    }
    ?>
    <!-- end of AutoOpenGraph tags -->
    And then it moves into charset, keywords, description...

  8. #18
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: AutoOpenGraph?

    Said earlier on that the file(s) were stored in the large directory... Is IH4 still on this site? Active? What is the path from the store's root to one of thefiles? Does the filename include some sort of large extension to the base name like it is supposed to have based on the above coding?
    It appers that the coding is "working", but does notfind the image. There is more error checking that could be done to support this, but need to get through the base operation...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 
Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg