Jump to content
Sign in to follow this  
alsmith

STS 4.5.8 template images

Recommended Posts

I am trying to take advantage of images in the template folder using this step in the installation:

2.6.7 includes/functions/html_output.php

Note: the modifications in this file allows to use images located in the templates folder instead of the in the original catalog/images folder. This is done by checking if the image exists or not in the templates folder, and to use it if yes. If you are not going to use this feature, you don't need to modify this file

Find:

function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {

Add after:

// START STS v4.4:
global $sts; 
$sts->image($src); // Take image from template folder if exists.
// END STS v4.4

 

I take it the Add after goes within the function between the { and } If I put it after the function I get

 

Fatal error: Call to a member function on a non-object in /home/ugi/public_html/shop/includes/functions/html_output.php on line 116

 

however if I put it

  function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '')
{
// START STS v4.4:
global $sts;
$sts->image($src); // Take image from template folder if exists.
// END STS v4.4
if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') )
{
  return false;
}

// alt is added to the img tag even if it is null to prevent browsers from outputt
ing
// the image filename as default
$image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_o
utput_string($alt) . '"';

if (tep_not_null($alt)) {
  $image .= ' title=" ' . tep_output_string($alt) . ' "';
}

if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($heigh
t)) ) {
  if ($image_size = @getimagesize($src)) {
	if (empty($width) && tep_not_null($height)) {
	  $ratio = $height / $image_size[1];
	  $width = intval($image_size[0] * $ratio);
	} elseif (tep_not_null($width) && empty($height)) {
	  $ratio = $width / $image_size[0];
	  $height = intval($image_size[1] * $ratio);
	} elseif (empty($width) && empty($height)) {
	  $width = $image_size[0];
	  $height = $image_size[1];
	}
  } elseif (IMAGE_REQUIRED == 'false') {
	return false;
  }
}

if (tep_not_null($width) && tep_not_null($height)) {
  $image .= ' width="' . tep_output_string($width) . '" height="' . tep_output
_string($height) . '"';
}

if (tep_not_null($parameters)) $image .= ' ' . $parameters;

$image .= '>';

return $image;
 }

 

Then in my template folder I place my own store_logo.png the template system does not seem to pick it up, still using the one in the catalog/images folder

has anyone accomplished this.

Share this post


Link to post
Share on other sites
I am trying to take advantage of images in the template folder using this step in the installation:

2.6.7 includes/functions/html_output.php

Note: the modifications in this file allows to use images located in the templates folder instead of the in the original catalog/images folder. This is done by checking if the image exists or not in the templates folder, and to use it if yes. If you are not going to use this feature, you don't need to modify this file

Find:

function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {

Add after:

// START STS v4.4:
global $sts; 
$sts->image($src); // Take image from template folder if exists.
// END STS v4.4

 

I take it the Add after goes within the function between the { and } If I put it after the function I get

 

Fatal error: Call to a member function on a non-object in /home/ugi/public_html/shop/includes/functions/html_output.php on line 116

 

however if I put it

  function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '')
{
// START STS v4.4:
global $sts;
$sts->image($src); // Take image from template folder if exists.
// END STS v4.4
if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') )
{
  return false;
}

// alt is added to the img tag even if it is null to prevent browsers from outputt
ing
// the image filename as default
$image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_o
utput_string($alt) . '"';

if (tep_not_null($alt)) {
  $image .= ' title=" ' . tep_output_string($alt) . ' "';
}

if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($heigh
t)) ) {
  if ($image_size = @getimagesize($src)) {
	if (empty($width) && tep_not_null($height)) {
	  $ratio = $height / $image_size[1];
	  $width = intval($image_size[0] * $ratio);
	} elseif (tep_not_null($width) && empty($height)) {
	  $ratio = $width / $image_size[0];
	  $height = intval($image_size[1] * $ratio);
	} elseif (empty($width) && empty($height)) {
	  $width = $image_size[0];
	  $height = $image_size[1];
	}
  } elseif (IMAGE_REQUIRED == 'false') {
	return false;
  }
}

if (tep_not_null($width) && tep_not_null($height)) {
  $image .= ' width="' . tep_output_string($width) . '" height="' . tep_output
_string($height) . '"';
}

if (tep_not_null($parameters)) $image .= ' ' . $parameters;

$image .= '>';

return $image;
 }

 

Then in my template folder I place my own store_logo.png the template system does not seem to pick it up, still using the one in the catalog/images folder

has anyone accomplished this.

 

:thumbsup: First of all, Please use the STS thread in the osCommerce forum to ask questions related to STS (you can use the link in my signature below: STSv4 Forum, same link as in the STS User Manual).

 

In regard to your post, just compare your edit with the file in the contribution. This will show you where you are to place the code.


Bill Kellum

 

Sounds Good Productions

STS Tutorials & more: STSv4.6, STS Add-ons (STS Power Pack), STS V4 Forum STS Forum FREE TEMPLATE

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×