Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

'On The Fly' Auto Thumbnailer using GD Library 2.1


mloeffen

Recommended Posts

Hi there,

 

I am having trouble with getting this working at all. The image still displays as normal without the expected

 

product_thumb.php?img=images/ part appended to the image tag.

 

The image url is

/x-scripts/oscommerce/images/OB12121.jpg

 

I have checked and rechecked all instructions and believe that I have all points as per instructions.

 

The other posts here seem to not cover my problem.

 

Any ideas where to start as I have run out of things to check or change.

 

Thanks in advance!

Link to comment
Share on other sites

  • Replies 556
  • Created
  • Last Reply

Top Posters In This Topic

HI,

 

I have just installed OTF 2.1.2 I have been able to get this working before. I have my catalog installed in catalog\new. I have created a thumbnails directory in the images folder and one in the root folder as said here. Still i get the red cross and no images, but if I click on enlarge, the image is fine. Is there anywhere where i can change the setting so it knows the path is catalog\new\images. My configure.php is set correctly

 

Giovanna

Link to comment
Share on other sites

i just uploaded new images for my status icon images (icon_status_green.gif) and now they're broken on admin/categories.php?cPath=10_10 (viewing item list for a category)

 

when i copy the image location, it shows up as: http://www.mysite.com/admin/product_thumb....t.gif&w=10&h=10

 

and of course, this is broken. cause these images are in the ADMIN directory... but for some reason the thumbnail contribution is looking in the catalog/images folder.

 

i tried placing a copy of these images in the /category/images folder, but they still remain broken.

 

any suggestions?

 

if possible, i would like to keep the thumbnailer from even knowing the status buttons exist... they're small enough to begin with ;)

Link to comment
Share on other sites

I installed On-the-Fly about a month ago, and it was working just fine. I recently realized that the thumbnails are no longer being optimized. The cached versions are in the thumbnail sub-directory of images, and they are the correct thumbnail size, but they are not being used. I checked over the installation to make sure everything was still as it should be. I have not added any major contributions since then, other than tax_optimization. Any ideas?

Link to comment
Share on other sites

I figured out what I had done - moved the store to the root (it was in /catalog) For those with problems with your store in the root directory, these are my settings

 

$tn_server_cache = true;
$tn_path = '/thumbnails/'; /

 

I made no other changes to the standard contribution install (follow the directions). The contribution is working and the reduced-sized thumbnails are being cached in the httpdoc/images/thumbnails directory. Incedently, my product images are in the 50 to 70 k, full size. I have the product_thumb quality set to 60%, which makes the thumbs in the <3k range. The thumbs are 120x150 - a bit on the small side, so the reduced quality does not effect them as much.

Link to comment
Share on other sites

i just uploaded new images for my status icon images (icon_status_green.gif) and now they're broken on admin/categories.php?cPath=10_10 (viewing item list for a category)

 

when i copy the image location, it shows up as: http://www.mysite.com/admin/product_thumb....t.gif&w=10&h=10

 

and of course, this is broken. cause these images are in the ADMIN directory... but for some reason the thumbnail contribution is looking in the catalog/images folder.

 

i tried placing a copy of these images in the /category/images folder, but they still remain broken.

 

any suggestions?

 

if possible, i would like to keep the thumbnailer from even knowing the status buttons exist... they're small enough to begin with ;)

anyone have any suggestions what i may have broken?

Link to comment
Share on other sites

  • 2 weeks later...

I have installed the "On The Fly Thumbnailer using GD Library" version 2.1.2 contribution exactly as described in the instructions.

 

Unfortunately all my thumbnails are displayed as broken links to images.

 

I will try to provide some info about my environment.

 

1. All of the configuration settings in the contribution are left in their default state.

 

2. oscommerce version is osCommerce 2.2-MS2

 

3. PHP Version 4.4.1

 

4. GD Support: enabled

GD Version: bundled (2.0.28 compatible)

FreeType Support enabled

FreeType Linkage with freetype

GIF Read Support enabled

GIF Create Support enabled

JPG Support enabled

PNG Support enabled

WBMP Support enabled

XBM Support enabled

 

5. In my oscommerce /catalog/includes/configure.php file the default setting was

 

define('DIR_WS_HTTP_CATALOG', '/catalog/');

define('DIR_WS_HTTPS_CATALOG', '/catalog/');

define('DIR_WS_IMAGES', '/catalog/images/');

 

I changed it to

 

define('DIR_WS_HTTP_CATALOG', '/catalog/');

define('DIR_WS_HTTPS_CATALOG', '/catalog/');

define('DIR_WS_IMAGES', 'images/');

 

6. I created one directory as /catalog/images/thumbnails (Write enabled)

 

7. Made all the other copy paste stuff as instructed

 

8. Arranged configuration in admin panel

 

Problems:

1. None of the thumbnails are displayed. They look like they have broken links.

2.Checked thumbnails folder and it was not populated with any of the thumbnails.

 

Did anyone have a similar problem?

 

How can I fix this.

 

Thanks

Edited by cruiser
Link to comment
Share on other sites

Try creating catalog/thumbnails/images, that was the only way I got it to work.

 

As I recall this is where the server side cache files are stored. If you disable caching your images should work fine, but with cache enabled it looks for that drirectory.

Edited by doctorstupid
Link to comment
Share on other sites

Try creating catalog/thumbnails/images, that was the only way I got it to work.

 

As I recall this is where the server side cache files are stored. If you disable caching your images should work fine, but with cache enabled it looks for that drirectory.

 

Thank you so much for the tip. Now I have optimized thumbnails. I do not know why this folder path was not mentioned in the instructions???!!!

 

Thanks again for your help.

 

Cihan

Link to comment
Share on other sites

OK, so I got it (GREAT CONTRIB, VERY PLEASED!) - but it seems as if my animated GIFs have now become static... o no! Anyone else encounter this problem? Is it an issue with my GB version or what?

JL

Edited by jlevi
Link to comment
Share on other sites

Just installed and no thumbs show up. When I hit view image I get this error

 

"/store/product_thumb.php?img=images/100_1036.jpg&w=100&h=75? cannot be displayed, because it contains errors."

 

I read through several posts and tried all these thumbnail folders tricks...placing them in root and in images and making /thumbs/images etc... is the instructions completely incorrect?

 

Also I am using GD v2.0.28, so I thought I would try something mentioned on the first page

 

"If you are using a gd-library version < 2.0.1 you should set $use_resampling to false (it's default set to true) in product_thumb.php.

In the same file, set $use_truecolor to false (default set to true) for the same reason as above."

 

but that didn't do anything. Any ideas?

Link to comment
Share on other sites

has anyone encountered the problem of some people's browsers not parsing the thumbnail url's:

http://www.mysite.com/product_thumb.php?im....gif&w=75&h=100

 

they show up as:

http://www.mysite.com/category/product_thu...;w=75&h=100

 

i've been getting a few 404's from these images on a regular basis now. on every computer i visited my site on works perfectly fine

Edited by eww
Link to comment
Share on other sites

QUOTE(doctorstupid @ Dec 19 2005, 01:41 AM)

 

Try creating catalog/thumbnails/images, that was the only way I got it to work.

 

As I recall this is where the server side cache files are stored. If you disable caching your images should work fine, but with cache enabled it looks for that drirectory.

 

 

Thank you so much for the tip. Now I have optimized thumbnails. I do not know why this folder path was not mentioned in the instructions???!!!

 

Thanks again for your help.

 

Cihan

 

I have the exact same problem as cruiser, but creating catalog/thumbnails/images still wont help! The only thing that helps is if I

 

change

$tn_server_cache = true;

to

$tn_server_cache = false;?

 

But I want the server cache to work!! Please help anyone?

Link to comment
Share on other sites

  • 1 month later...

hi, i installed it but it returns me this error

 

Fatal error: Cannot redeclare tep_image() (previously declared in /web/htdocs/www.abcpoint.it/home/abc/includes/functions/html_output.php:17) in /web/htdocs/www.abcpoint.it/home/abc/includes/functions/html_output.php on line 101

 

 

Can you help me? My php is ... ehm

 

here is my code

<?php

/*

$Id: html_output.php,v 1.56 2003/07/09 01:15:48 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

////

// "On the Fly" Auto Thumbnailer using GD Library, servercaching and browsercaching

// Scales product images dynamically, resulting in smaller file sizes, and keeps

// proper image ratio. Used in conjunction with product_thumb.php t/n generator.

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

 

// Set default image variable and code

$image = '<img src="' . $src . '"';

 

// Don't calculate if the image is set to a "%" width

if (strstr($width,'%') == false || strstr($height,'%') == false) {

$dont_calculate = 0;

} else {

$dont_calculate = 1;

}

 

// Dont calculate if a pixel image is being passed (hope you dont have pixels for sale)

if (!strstr($image, 'pixel')) {

$dont_calculate = 0;

} else {

$dont_calculate = 1;

}

 

// Do we calculate the image size?

if (CONFIG_CALCULATE_IMAGE_SIZE && !$dont_calculate) {

 

// Get the image's information

if ($image_size = @getimagesize($src)) {

 

$ratio = $image_size[1] / $image_size[0];

 

// Set the width and height to the proper ratio

if (!$width && $height) {

$ratio = $height / $image_size[1];

$width = intval($image_size[0] * $ratio);

} elseif ($width && !$height) {

$ratio = $width / $image_size[0];

$height = intval($image_size[1] * $ratio);

} elseif (!$width && !$height) {

$width = $image_size[0];

$height = $image_size[1];

}

 

// Scale the image if not the original size

if ($image_size[0] != $width || $image_size[1] != $height) {

$rx = $image_size[0] / $width;

$ry = $image_size[1] / $height;

 

if ($rx < $ry) {

$width = intval($height / $ratio);

} else {

$height = intval($width * $ratio);

}

 

$image = '<img src="product_thumb.php?img='.$src.'&w='.

tep_output_string($width).'&h='.tep_output_string($height).'"';

}

 

} elseif (IMAGE_REQUIRED == 'false') {

return '';

}

}

 

// Add remaining image parameters if they exist

if ($width) {

$image .= ' width="' . tep_output_string($width) . '"';

}

 

if ($height) {

$image .= ' height="' . tep_output_string($height) . '"';

}

 

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

 

$image .= ' border="0" alt="' . tep_output_string($alt) . '"';

 

if (tep_not_null($alt)) {

$image .= ' title="' . tep_output_string($alt) . '"';

}

 

$image .= '>';

 

return $image;

}

 

 

////

// The HTML image wrapper function

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

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 outputting

// the image filename as default

$image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"';

 

if (tep_not_null($alt)) {

$image .= ' title=" ' . tep_output_string($alt) . ' "';

}

 

if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height)) ) {

if ($image_size = @getimagesize($src)) {

if (empty($width) && tep_not_null($height)) {

$ratio = $height / $image_size[1];

$width = $image_size[0] * $ratio;

} elseif (tep_not_null($width) && empty($height)) {

$ratio = $width / $image_size[0];

$height = $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;

}

 

////

// The HTML form submit button wrapper function

// Outputs a button in the selected language

function tep_image_submit($image, $alt = '', $parameters = '') {

global $language;

 

$image_submit = '<input type="image" src="' . tep_output_string(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image) . '" border="0" alt="' . tep_output_string($alt) . '"';

 

if (tep_not_null($alt)) $image_submit .= ' title=" ' . tep_output_string($alt) . ' "';

 

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

 

$image_submit .= '>';

 

return $image_submit;

}

 

////

// Output a function button in the selected language

function tep_image_button($image, $alt = '', $parameters = '') {

global $language;

 

return tep_image(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image, $alt, '', '', $parameters);

}

 

////

// Output a separator either through whitespace, or with an image

function tep_draw_separator($image = 'pixel_black.gif', $width = '100%', $height = '1') {

return tep_image(DIR_WS_IMAGES . $image, '', $width, $height);

}

 

////

// Output a form

function tep_draw_form($name, $action, $method = 'post', $parameters = '') {

$form = '<form name="' . tep_output_string($name) . '" action="' . tep_output_string($action) . '" method="' . tep_output_string($method) . '"';

 

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

 

$form .= '>';

 

return $form;

}

 

////

// Output a form input field

function tep_draw_input_field($name, $value = '', $parameters = '', $type = 'text', $reinsert_value = true) {

$field = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"'.($type = 'text' ? ' class=go' : '');

 

if ( (isset($GLOBALS[$name])) && ($reinsert_value == true) ) {

$field .= ' value="' . tep_output_string(stripslashes($GLOBALS[$name])) . '"';

} elseif (tep_not_null($value)) {

$field .= ' value="' . tep_output_string($value) . '"';

}

 

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

 

$field .= '>';

 

return $field;

}

 

////

// Output a form password field

function tep_draw_password_field($name, $value = '', $parameters = 'maxlength="40"') {

return tep_draw_input_field($name, $value, $parameters, 'password', false);

}

 

////

// Output a selection field - alias function for tep_draw_checkbox_field() and tep_draw_radio_field()

function tep_draw_selection_field($name, $type, $value = '', $checked = false, $parameters = '') {

$selection = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';

 

if (tep_not_null($value)) $selection .= ' value="' . tep_output_string($value) . '"';

 

if ( ($checked == true) || ( isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && ( ($GLOBALS[$name] == 'on') || (isset($value) && (stripslashes($GLOBALS[$name]) == $value)) ) ) ) {

$selection .= ' CHECKED';

}

 

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

 

$selection .= '>';

 

return $selection;

}

 

////

// Output a form checkbox field

function tep_draw_checkbox_field($name, $value = '', $checked = false, $parameters = '') {

return tep_draw_selection_field($name, 'checkbox', $value, $checked, $parameters);

}

 

////

// Output a form radio field

function tep_draw_radio_field($name, $value = '', $checked = false, $parameters = '') {

return tep_draw_selection_field($name, 'radio', $value, $checked, $parameters);

}

 

////

// Output a form textarea field

function tep_draw_textarea_field($name, $wrap, $width, $height, $text = '', $parameters = '', $reinsert_value = true) {

$field = '<textarea name="' . tep_output_string($name) . '" wrap="' . tep_output_string($wrap) . '" cols="' . tep_output_string($width) . '" rows="' . tep_output_string($height) . '"';

 

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

 

$field .= '>';

 

if ( (isset($GLOBALS[$name])) && ($reinsert_value == true) ) {

$field .= stripslashes($GLOBALS[$name]);

} elseif (tep_not_null($text)) {

$field .= $text;

}

 

$field .= '</textarea>';

 

return $field;

}

 

////

// Output a form hidden field

function tep_draw_hidden_field($name, $value = '', $parameters = '') {

$field = '<input type="hidden" name="' . tep_output_string($name) . '"';

 

if (tep_not_null($value)) {

$field .= ' value="' . tep_output_string($value) . '"';

} elseif (isset($GLOBALS[$name])) {

$field .= ' value="' . tep_output_string(stripslashes($GLOBALS[$name])) . '"';

}

 

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

 

$field .= '>';

 

return $field;

}

 

////

// Hide form elements

function tep_hide_session_id() {

global $session_started, $SID;

 

if (($session_started == true) && tep_not_null($SID)) {

return tep_draw_hidden_field(tep_session_name(), tep_session_id());

}

}

 

////

// Output a form pull down menu

function tep_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {

$field = '<select name="' . tep_output_string($name) . '"';

 

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

 

$field .= '>';

 

if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]);

 

for ($i=0, $n=sizeof($values); $i<$n; $i++) {

$field .= '<option value="' . tep_output_string($values[$i]['id']) . '"';

if ($default == $values[$i]['id']) {

$field .= ' SELECTED';

}

 

$field .= '>' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>';

}

$field .= '</select>';

 

if ($required == true) $field .= TEXT_FIELD_REQUIRED;

 

return $field;

}

 

////

// Creates a pull-down list of countries

function tep_get_country_list($name, $selected = '', $parameters = '') {

$countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));

$countries = tep_get_countries();

 

for ($i=0, $n=sizeof($countries); $i<$n; $i++) {

$countries_array[] = array('id' => $countries[$i]['countries_id'], 'text' => $countries[$i]['countries_name']);

}

 

return tep_draw_pull_down_menu($name, $countries_array, $selected, $parameters);

}

?>

 

Thank you!

Link to comment
Share on other sites

hi, i installed it but it returns me this error

 

Fatal error: Cannot redeclare tep_image() (previously declared in /web/htdocs/www.abcpoint.it/home/abc/includes/functions/html_output.php:17) in /web/htdocs/www.abcpoint.it/home/abc/includes/functions/html_output.php on line 101

Can you help me? My php is ... ehm

 

here is my code

Thank you!

In the included readme on step #6 it tells you to replace the tep_image function. You added the new version of the function, but did not delete the old one. So look for the function tep_image and remove the second one. The following lines should be deleted:

 

////
// The HTML image wrapper function
function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {
if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
return false;
}

 

P.S. In the future try not to paste lots of code here. Instead give the errormessage(s) you get, explain what you are trying to accomplish and what have done so far to troubleshoot :)

Edited by mloeffen
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...