Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2009
    Posts
    52
    Plugin Contributions
    0

    Default Call Larger Images

    Hi, I have searched the forum all morning and have not found the answer to this question, however, I apologize if this question has been already asked. On my current site I only use small and large images. I have installed a facebook like button for my products (that works great by the way) however I have one small problem with it... My small images are 150 x 150 and facebook is telling me that my images should be at least 200 x 200. I would like to call the large image instead of the small image. I have been trying to dig into the php files to try to figure this out however I think I am too much a noob with php... I think I know how to do it I just do not know the proper code to get it done...... Here is my current facebook image code...
    Code:
    <?php
      if (isset($_GET['products_id'])) { // use products_image if products_id exists
        $facebook_image = $db->Execute("select p.products_image from " . TABLE_PRODUCTS . " p where products_id='" . (int)$_GET['products_id'] . "'");
        $fb_image = HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $facebook_image->fields['products_image'];
      }
      if ($fb_image == '') { // if no products image, use the default image if enabled
       $fb_image = 'http://www.store.com/includes/templates/scb/images/logo.gif';
      }
      if ($fb_image != '') {
    ?>
    <meta property="og:image" content="<?php echo $fb_image; ?>" />
    I tried a few things to get the larger image to appear and managed to get to the correct directory and what would be the correct image if it did have the _lrg tag on it... I assume there is a way in php to add the _lrg tag to the end of the image name (before the extension) I just do not know how to do this properly.....

  2. #2
    Join Date
    Jan 2004
    Posts
    58,235
    Blog Entries
    3
    Plugin Contributions
    106

    Default Re: Call Larger Images

    Quote Originally Posted by Goetch View Post
    Here is my current facebook image code...
    Code:
    <?php
      if (isset($_GET['products_id'])) { // use products_image if products_id exists
        $facebook_image = $db->Execute("select p.products_image from " . TABLE_PRODUCTS . " p where products_id='" . (int)$_GET['products_id'] . "'");
        $fb_image = HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $facebook_image->fields['products_image'];
      }
      if ($fb_image == '') { // if no products image, use the default image if enabled
       $fb_image = 'http://www.store.com/includes/templates/scb/images/logo.gif';
      }
      if ($fb_image != '') {
    ?>
    <meta property="og:image" content="<?php echo $fb_image; ?>" />
    I'd be inclined to replace all that with this instead:
    Code:
    <?php
    // default image:
    $fb_image = HTTP_SERVER . DIR_WS_CATALOG . 'includes/templates/scb/images/logo.gif';
    if (isset($_GET['products_id'])) { // use products_image if products_id exists
      $facebook_image = $db->Execute("select p.products_image from " . TABLE_PRODUCTS . " p where products_id='" . (int)$_GET['products_id'] . "'");
      $prod_image = $facebook_image->fields['products_image'];
      $prod_image_extension = substr($prod_image, strrpos($prod_image, '.'));
      $prod_image_base = str_replace($prod_image_extension, '', $prod_image);
      $prod_image_large = $prod_image_base . IMAGE_SUFFIX_LARGE . $prod_image_extension;
      
      if (file_exists(DIR_WS_IMAGES . 'large/' . $prod_image_large)) {
        $prod_image = DIR_WS_IMAGES . 'large/' . $prod_image_large;
      }
      $fb_image = HTTP_SERVER . DIR_WS_CATALOG . $prod_image;
    }
      if ($fb_image != '') {
    ?>
    <meta property="og:image" content="<?php echo $fb_image; ?>" />
    <?php } ?>
    First, it sets a default up-front, which makes things simpler later.
    Then it reads the image from the database, parses it into its parts, inserts the "lrg" bit, checks if the file exists, and if it does, then it replaces the value set as default earlier.
    Then it carries on to output it as you were doing before.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donations always welcome: www.zen-cart.com/donate

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Dec 2009
    Posts
    52
    Plugin Contributions
    0

    Default Re: Call Larger Images

    Your the best thank you so much!!!! Very helpful!!!

  4. #4
    Join Date
    Jan 2004
    Posts
    58,235
    Blog Entries
    3
    Plugin Contributions
    106

    Default Re: Call Larger Images

    Actually, since the system has already determined the available images, you could probably save the database query and the more complex logic, and just use the already-available information, like this instead:
    Code:
    <?php
    $fb_image = HTTP_SERVER . DIR_WS_CATALOG . 'includes/templates/scb/images/logo.gif';
    if ($products_image_large != '') $fb_image = HTTP_SERVER . DIR_WS_CATALOG . $products_image_large;
    ?>
    <meta property="og:image" content="<?php echo $fb_image; ?>" />
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donations always welcome: www.zen-cart.com/donate

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. Larger images
    By dstegall in forum General Questions
    Replies: 3
    Last Post: 10 Nov 2011, 07:00 PM
  2. Larger images and additional images - Thanks!
    By EJTOPP in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 4 Aug 2011, 08:12 AM
  3. Larger images not getting larger
    By numberger in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 29 Sep 2009, 07:20 PM
  4. Larger product images
    By hemdawg in forum General Questions
    Replies: 4
    Last Post: 18 May 2006, 10:59 PM

Bookmarks

Posting Permissions

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