Difference between revisions of "Contribution:Web images"

From Zen Cart(tm) Wiki
Jump to: navigation, search
 
Line 1: Line 1:
 
For my showcase application I wanted to show images directly linked from an external site and not only store them on the local server; nevertheless both methods are working.
 
For my showcase application I wanted to show images directly linked from an external site and not only store them on the local server; nevertheless both methods are working.
  
I changed the database filed length to accept longer names and I may now enter a Products_image like _http://www.siteurl.com/images/externalimage.jpg.
+
I changed the database field length to accept longer names and I may now enter a Products_image like <nowiki>http://www.siteurl.com/images/externalimage.jpg.</nowiki>
  
 
I have changed some code and the result may be seen at [http://www.rcmarket.net/products rcmarket.net].
 
I have changed some code and the result may be seen at [http://www.rcmarket.net/products rcmarket.net].

Latest revision as of 18:43, 4 November 2006

For my showcase application I wanted to show images directly linked from an external site and not only store them on the local server; nevertheless both methods are working.

I changed the database field length to accept longer names and I may now enter a Products_image like http://www.siteurl.com/images/externalimage.jpg.

I have changed some code and the result may be seen at rcmarket.net.

Changes:

includes\functions\html_output.php line 165:

//by rl if image is located on the web, strip any local path  
    if (strstr($src, 'http') != '0') {
	  $src = strstr($src, 'http://');
	}

    // use old method on template images  by rl: test for http
    if (strstr($src, 'includes/templates') or strstr($src, 'includes/languages') or PROPORTIONAL_IMAGES_STATUS == '0'  or strstr($src, 'http') != '0' ) {
      return zen_image_OLD($src, $alt, $width, $height, $parameters);
    }

includes\modules\pages\popup_image\header_php.php line 45:

//by rl  if start of path = http then link to external site's image, only small image may have a http address
           $imagepath = DIR_WS_IMAGES;
           if (substr($products_image,0,4) == 'http') {
               $imagepath ='';
           }

includes\modules\featured_products.php line 52:

        //by rl  if start of path = http then link to external site's image
        //replace DIR_WS_IMAGES with variable $imagepath
           $imagepath = DIR_WS_IMAGES;
           if (substr($listing->fields['products_image'],0,4) == 'http') {
               $imagepath ='';
           }


   $list_box_contents[$row][$col] = array('params' =>'class="centerBoxContentsFeatured centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
   'text' => '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . zen_image($imagepath . $featured_products->fields['products_image'], $featured_products->fields['products_name'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT) . '</a>
<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . $featured_products->fields['products_name'] . '</a>
' . $products_price);

includes\modules\new_products.php line 56:

similar to above

includes\modules\product_listing.php line 162:

 //by rl  if start of path = http then link to external site's image
           $imagepath = DIR_WS_IMAGES;
           if (substr($listing->fields['products_image'],0,4) == 'http') {
               $imagepath ='';            }
          
       
       if (isset($_GET['manufacturers_id'])) {
         $lc_text = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'products_id=' . $listing->fields['products_id']) . '">' . zen_image($imagepath . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH, IMAGE_PRODUCT_LISTING_HEIGHT, 'class="listingProductImage"') . '</a>';
       } else {
         $lc_text = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : ) . 'products_id=' . $listing->fields['products_id']) . '">' . zen_image($imagepath . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH, IMAGE_PRODUCT_LISTING_HEIGHT, 'class="listingProductImage"') . '</a>';
       }
       break;

includes\modules\specials_index.php line 51:

//by rl  if start of path = http then link to external site's image
           $imagepath = DIR_WS_IMAGES;
           if (substr($specials_index->fields['products_image'],0,4) == 'http') {
               $imagepath ='';
           }


   $products_price = zen_get_products_display_price($specials_index->fields['products_id']);
   $specials_index->fields['products_name'] = zen_get_products_name($specials_index->fields['products_id']);
   $list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsSpecials centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
   'text' => '<a href="' . zen_href_link(zen_get_info_page($specials_index->fields['products_id']), 'products_id=' . (int)$specials_index->fields['products_id']) . '">' . zen_image($imagepath . $specials_index->fields['products_image'], $specials_index->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>
<a href="' . zen_href_link(zen_get_info_page($specials_index->fields['products_id']), 'products_id=' . $specials_index->fields['products_id']) . '">' . $specials_index->fields['products_name'] . '</a>
' . $products_price);


includes\templates\template_default\popup_image_additional\tpl_main_page.php line 19:

 //by rl  if start of path = http then link to external site's image
           $imagepath = DIR_WS_IMAGES;
           if (substr($listing->fields['products_image'],0,4) == 'http') {
               $imagepath ='';
           }
   echo '<a href="javascript:window.close()">' . zen_image($imagepath . $products_image, $products_values->fields['products_name'] . ' ' . TEXT_CLOSE_WINDOW) . '</a>';
 }

includes\templates\template_default\sideboxes\tpl_reviews_random.php line 10:

//by rl if start of path = http then link to external site's image

           $imagepath = DIR_WS_IMAGES;
           if (substr($random_product->fields['products_image'],0,4) == 'http') {
               $imagepath ='';            }
        
 $content = "";
  $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent centeredContent">';
  $content .= '<a href="' . zen_href_link(FILENAME_PRODUCT_REVIEWS_INFO, 'products_id=' . $random_review_sidebox_product->fields['products_id'] . '&reviews_id=' . $random_review_sidebox_product->fields['reviews_id']) . '">' . zen_image($imagepath . $random_review_sidebox_product->fields['products_image'], $random_review_sidebox_product->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '
' . $review_box_text . ' ..</a>

' . zen_image(DIR_WS_TEMPLATE_IMAGES . 'stars_' . $random_review_sidebox_product->fields['reviews_rating'] . '.gif' , sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, $random_review_sidebox_product->fields['reviews_rating'])); $content .= '</div>';