Jump to content
Parikesit

[Contribution] OPI: OsC Product Image Module

Recommended Posts

All is working great, one final comment -

 

I am running a linux server - when creating a new directory it creates itself with a CHMOD 700 -

 

opi_thumnails.php - i have tiried 755 or 777, but the diredtcory still creates itself with CHMOD 700 -

 

 

Is there something I have missed?

 

Any help would be great as other than that its a seriously great contrib!

 

Cheers

Share this post


Link to post
Share on other sites

 

Do you use IIS or Apache? It's seem OPI can not find your image folder. Please make some test below:

  • Assuming that your domain is domain.com, installed oscommerce in root directory, and you have an image in root_directory/images/products/virtual_image.png, can you view this image using URL http: // domain.com/images/thumbs/def/adminthumb/virtual_image.png ? If you can not see the image using this URL, your problem should be in your htaccess, etc.
  • (If you pass point above) What the value of configuration below when editing product. View source and find similar line below

 var oscProductImageHelper = {

 ...
 imageURL: ???,
 ...
}

 

If you use Apache with modrewrite, its should be:

imageURL: {path:'http://domain.com/images/', relative:'products/', medium:'http://domain.com/images/thumbs/def/adminpreview/', small:'http://domain.com/images/thumbs/def/adminthumb/', transparent:'images/pixel_trans.gif'},

 

Otherwise, if you use IIS its should be:

 

imageURL: {path:'http://domain.com/images/', relative:'products/', medium:'http://domain.com/opi_thumbnail.php?def=adminpreview', small:'http://domain.com/opi_thumbnail.php?def=adminthumb', transparent:'images/pixel_trans.gif'},

 

Cheers,

@zaenal

Share this post


Link to post
Share on other sites

Hi Johnatan,

 

Maybe you can replace your code like below:

 

////
// The HTML image wrapper function
if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
$src=DIR_WS_IMAGES.'thumbs/def/display/nopic.jpg';
//no image url when you upload the product.
}
//over

 

 

 

 

here is the code:

catalog/includes/functions/html_output.php

////
// The HTML image wrapper function
if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
$src=DIR_WS_IMAGES.'nopic.jpg';
//no image url when you upload the product.
}
//for what`s the url like :'images/aa/'
if(!file_exists($src)||strlen(strstr($src,"."))<=0){
$src=DIR_WS_IMAGES.'nopic.jpg';
}
//over

 

 

greeting from croatia

J.

 

Cheers,

@zaenal

Share this post


Link to post
Share on other sites

opi_thumnails.php - i have tiried 755 or 777, but the diredtcory still creates itself with CHMOD 700 -

 

Hi Gemma,

 

Open file in admin: /includes/classes/productImageHandler.php, and replace below line

if (mkdir($dest . $new_folder)) {

with this one

if (mkdir($dest . $new_folder, 0755)) {

 

Hope that help.

 

Note: It's seem OPI need one more configuration for handling this. So it's can be configured from admin page.

 

Thanks,

@zaenal

Share this post


Link to post
Share on other sites

Hi zaenal,

 

I hate to be a pain and bring up something that you've already been through but I cannot get my images to show up on my products page. I followed the instructions for manually editing the required files (I already have a fairly modified osC) and the admin side works fine and everything is inserted into the database properly.

My server has mod rewrite enabled and I have tried a direct link to the images and using the /thumbs/def/***** url, both of which work fine.

 

Absolute path:

http://www.rain-e-daze.co.uk/shop/images/products/0-3-months-yellow-lily-1.jpg

Thumbnail paths:

http://www.rain-e-daze.co.uk/shop/images/thumbs/def/display/products/0-3-months-yellow-lily-1.jpg

http://www.rain-e-daze.co.uk/shop/images/thumbs/def/small/products/0-3-months-yellow-lily-1.jpg

http://www.rain-e-daze.co.uk/shop/images/thumbs/def/large/products/0-3-months-yellow-lily-1.jpg

 

But I still get the spinning 'loading' image on my product_info.php.

I already had this file modified with QTPro 4.6.1 so I used winmerge to compare the differences I thought I had it all ok. Apparently not.

I'm not great with .htaccess files so there may be a problem with it, I don't know.

Any ideas on where to look would be grateful. If you need more info, just say so.

 

Thanks,

Graham


Not enough time in the day. Need a time machine...

 

Would build one, but not enough time. Ironically.

Share this post


Link to post
Share on other sites

Absolute path:

http://www.rain-e-da...llow-lily-1.jpg

Thumbnail paths:

http://www.rain-e-da...llow-lily-1.jpg

http://www.rain-e-da...llow-lily-1.jpg

http://www.rain-e-da...llow-lily-1.jpg

 

But I still get the spinning 'loading' image on my product_info.php.

 

Hi Graham,

 

I have no idea why it's did not show up on your product info page, because the thumbnail images work properly. I try to access your store but seem it's on "maintenance" mode...

 

Try to "view source" and find the IMG tag that load thumbnail image. How it look like? Does the SRC attribute pointing to the right URL?

 

<img src=".../images/thumbs/def/display/products/0-3-months-yellow-lily-1.jpg" />

 

@zaenal

Share this post


Link to post
Share on other sites

 

Hi Gemma,

 

Open file in admin: /includes/classes/productImageHandler.php, and replace below line

if (mkdir($dest . $new_folder)) {

with this one

if (mkdir($dest . $new_folder, 0755)) {

 

Hope that help.

 

Note: It's seem OPI need one more configuration for handling this. So it's can be configured from admin page.

 

Thanks,

@zaenal

 

 

 

Thanks for the post - no joy im affraid - still 700...- please post me any further suggestions to try.

 

Many Thanks

Share this post


Link to post
Share on other sites

I am running a linux server - when creating a new directory it creates itself with a CHMOD 700 -

 

opi_thumnails.php - i have tiried 755 or 777, but the diredtcory still creates itself with CHMOD 700 -

 

On linux you should use octal value with leading zero. On opi_thumbnail.php find OPI_FS_CHMOD, and set 0755

 

define('OPI_FS_CHMOD', 0755);

 

 

If you can't find OPI_FS_CHMOD on that file, I'm afraid you use older version. Download the new one here: http://addons.oscommerce.com/info/8139

Edited by Parikesit

Share this post


Link to post
Share on other sites

 

Try to "view source" and find the IMG tag that load thumbnail image. How it look like? Does the SRC attribute pointing to the right URL?

 

<img src=".../images/thumbs/def/display/products/0-3-months-yellow-lily-1.jpg" />

 

@zaenal

 

Sorry zaenal,

I forgot about the Maintenance mode. My pc bypasses it. I've turned it off now so you can see it if you need to.

I've been crawling through the code all evening trying to find the cause and I think I have, but not a solution. It turns out that my tep_image() function doesn't work with 'thumbs/def/****' in the path. There is no "<img src=" at all in the html source because the function doesn't output. I can't figure out why.

If I take out the relative thumbs/ path and have an absolute path to the image on the server then it will display it. The href links work and I can see them in the source just not the actual images themselves.

 

It's probably worth noting that I've tried this with 1 picture on a product and 4 pictures on a product. No images display either way.. At the moment the only products with more than one image are:

 

http://www.rain-e-daze.co.uk/shop/product_info.php/cPath/29_30/products_id/43

and

http://www.rain-e-daze.co.uk/shop/product_info.php/cPath/29_30/products_id/51

 

Thanks for your input,

Graham


Not enough time in the day. Need a time machine...

 

Would build one, but not enough time. Ironically.

Share this post


Link to post
Share on other sites

 

On linux you should use octal value with leading zero. On opi_thumbnail.php find OPI_FS_CHMOD, and set 0755

 

define('OPI_FS_CHMOD', 0755);

 

 

If you can't find OPI_FS_CHMOD on that file, I'm afraid you use older version. Download the new one here: http://addons.oscommerce.com/info/8139

 

 

 

------------

 

 

I am using the lastest version and my opi_thumbnail.php reads:

 

define('OPI_FS_CHMOD', 0755); // some servers required 0775 or 0777

 

 

-----------------

 

Still no joy - the folder being created is CHMOD still 0700............

 

Does any else have this issue? It only occurs when creating a new directory.

Share this post


Link to post
Share on other sites

Still no joy - the folder being created is CHMOD still 0700............

 

Does any else have this issue? It only occurs when creating a new directory.

 

Never seen it... I'm not linux expert, but this could be happen on some server that appoint specific privilege (user and user group) to PHP.

 

Another workaround, try to CHMOD the folder manually. Open opi_thumbnail.php, and find @mkdir(OPI_FS_IMAGES_OPI_THUMB . $subdir, OPI_FS_CHMOD), and make some change like below:

 

//check directory
$dirs = explode(DIRECTORY_SEPARATOR, $imMode['thumb']);
$subdir = '';
for ($i=0; $i < sizeof($dirs)-1; $i++) {
	$subdir .= $dirs[$i] . DIRECTORY_SEPARATOR;
	if (!is_dir(OPI_FS_IMAGES_OPI_THUMB . $subdir)) {
		@mkdir(OPI_FS_IMAGES_OPI_THUMB . $subdir);
	}
	@chmod(OPI_FS_IMAGES_OPI_THUMB . $subdir, OPI_FS_CHMOD);
}

 

@zaenal

Share this post


Link to post
Share on other sites

There is no error on your opi_thumbnail.php and .htaccess. I try to access your rain_light.gif and 0-3-months-yellow-lily.jpg using opi thumbnailer, and it's works:

It's probably worth noting that I've tried this with 1 picture on a product and 4 pictures on a product. No images display either way..

 

I guess the problem come from your tep_image function. Did you add an addon that modify tep_image function? Well, if you add file_exists check to tep_image, the result will always null because the thumbnail is generated on-the-fly by opi_thumbnail.php.

 

Just try to write IMG tag without tep_image on your product_info.php:

 

<?php
if (tep_not_null($product_info['products_image'])) {
  //$pi_query = tep_db_query("select image, htmlcontent from " . TABLE_PRODUCTS_IMAGES . " where products_id = '" . (int)$product_info['products_id'] . "' order by sort_order");
  $products_images = explode(',', $product_info['products_images']);
  if (sizeof($products_images) > 1) {		
?>
<div id="piGal" style="float: right;">
  <ul>
<?php
	$pi_counter = 0;
	foreach ($products_images as $pi) {
		$pi_counter++;
		$pi_entry = '		<li><a href="';
		$pi_entry .= tep_href_link(DIR_WS_IMAGES . 'thumbs/def/large/' . $pi);
		$pi_entry .= '" target="_blank" rel="fancybox"><img src="' . tep_href_link(DIR_WS_IMAGES . 'thumbs/def/display/' . $pi) . '" /></a>';
		$pi_entry .= '</li>';
		echo $pi_entry;
	}
?>
  </ul>
</div>
<script type="text/javascript">
$('#piGal ul').bxGallery({
 maxwidth: 300,
 maxheight: 200,
 thumbwidth: <?php echo (($pi_counter > 1) ? '75' : '0'); ?>,
 thumbcontainer: 300,
 load_image: 'ext/jquery/bxGallery/spinner.gif'
});
</script>
<?php
  } else {
?>
<div id="piGal" style="float: right;">
  <?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . 'thumbs/def/large/' . $product_info['products_image']) . '" target="_blank" rel="fancybox"><img src="' . tep_href_link(DIR_WS_IMAGES . 'thumbs/def/display/' . $product_info['products_image']) . '" alt="' . addslashes($product_info['products_name']) . '" hspace="5" vspace="5" /></a>'; ?>
</div>
<?php
  }
?>
<script type="text/javascript">
$("#piGal a[rel^='fancybox']").fancybox({
 cyclic: true
});
</script>
<?php
}
?>

 

 

@zaenal

Share this post


Link to post
Share on other sites

GOT IT!!!!

 

productImageHandler.php

 

if (!$this->error) {

if (mkdir($dest . $new_folder, 0755)) {

$this->error = 0;

@chmod($dest . $new_folder, 0755);

Share this post


Link to post
Share on other sites

 

Some others suggestion...

  • Your product list (index.php) seem still use default image (a big one) that slowdown your site. Try to use opi thumbnail to display your product image everywhere.
  • Files that display product image
    • product_info.php (done)
    • popup_image.php
    • product_reviews.php
    • product_reviews_info.php
    • product_reviews_write.php
    • products_new.php
    • reviews.php
    • shopping_cart.php
    • specials.php
    • includes/modules/also_purchased_products.php
    • includes/modules/new_products.php
    • includes/modules/product_listing.php (!important)
    • includes/modules/boxes/bm_reviews.php
    • includes/modules/boxes/bp_specials.php
    • includes/modules/boxes/bm_whats_new.php

Just use the same method as product_info.php. Below an example to edit includes/modules/product_listing.php file...

 

Find...

	  case 'PRODUCT_LIST_IMAGE':
		if (isset($HTTP_GET_VARS['manufacturers_id'])  && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
		  $prod_list_contents .= '		<td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id'] . '&products_name=' . $listing['products_name']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>';
		} else {
		  $prod_list_contents .= '		<td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id'] . '&products_name=' . $listing['products_name']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>';
		}
		break;

 

Replace with:

--here we use "thumbs/def/small/" but you can use other "def", or just edit opi_thumbnail.php to fit your need.

	  case 'PRODUCT_LIST_IMAGE':
		if (isset($HTTP_GET_VARS['manufacturers_id'])  && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
		  $prod_list_contents .= '		<td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '"><img src="' . tep_href_link(DIR_WS_IMAGES . 'thumbs/def/small/' . $listing['products_image']) . '" alt="' . $listing['products_name'] . '" /></a></td>';
		} else {
		  $prod_list_contents .= '		<td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '"><img src="' . tep_href_link(DIR_WS_IMAGES . 'thumbs/def/small/' . $listing['products_image']) . '" alt="' . $listing['products_name'] . '" /></a></td>';
		}
		break;

 

@zaenal

Edited by Parikesit

Share this post


Link to post
Share on other sites

GOT IT!!!!

 

productImageHandler.php

 

if (!$this->error) {

if (mkdir($dest . $new_folder, 0755)) {

$this->error = 0;

@chmod($dest . $new_folder, 0755);

 

Glad to hear that.

Share this post


Link to post
Share on other sites

I guess the problem come from your tep_image function. Did you add an addon that modify tep_image function?

 

Actually I haven't touched the html_output.php or the general.php files at all so I don't know what's going on. If I find out I'll let you know just in case you come across it again.

 

Some others suggestion...

  • Your product list (index.php) seem still use default image (a big one) that slowdown your site. Try to use opi thumbnail to display your product image everywhere.

 

Thank you. This was the reason I was trying to get this to work. I wanted to thumbnail the images everywhere but not have to make copies. I'd only just started to implement OPI so I hadn't reached all the files yet. Just finishing that off now.

I didn't say it before but this contribution is amazing. Just what I needed, thank you.

 

 

Off topic question: I noticed on the demo site that you linked to earlier (http://www.rhinebutik.com/en/product_info.php?products_id=2) that you had a drop down box that changes depending on the option selected. Do you know of any contributions that do something like that?

 

 

Many thanks again for all your help,

Graham


Not enough time in the day. Need a time machine...

 

Would build one, but not enough time. Ironically.

Share this post


Link to post
Share on other sites

Off topic question: I noticed on the demo site that you linked to earlier (http://www.rhinebuti...p?products_id=2) that you had a drop down box that changes depending on the option selected. Do you know of any contributions that do something like that?

 

There is an addon "Stock View with Quantity per Attribute" out there, but I did not know how the frontpage look like. But I guess it's easy to create some javascript function using jQuery to get similar output.

 

As for the site mentioned, I did not use that addon but created myself, including the backend and frontend. I also use prototypejs instead of jQuery for frontpage catalog.

 

@zaenal

Share this post


Link to post
Share on other sites

Hello,

 

I am having trouble installing this add on to my page. Everything seems to work fine, except for whatever reason, there is no modRewrite option available in my admin panel. Every other option is there, but there simply isn't a way for me to enable or disable modRewrite. I am using OSC Version 2.3, and I am attempting to use OPI V 2.0.

 

Has this problem happened to anyone else? What file would the modRewrite information be in? I checked opi_prodcutimage.php, and it seems like that's where it'd be, but I don't see any code that would implement it. Any help is appreciated. Thanks!

Share this post


Link to post
Share on other sites

Hello,

 

I am having trouble installing this add on to my page. Everything seems to work fine, except for whatever reason, there is no modRewrite option available in my admin panel. Every other option is there, but there simply isn't a way for me to enable or disable modRewrite. I am using OSC Version 2.3, and I am attempting to use OPI V 2.0.

 

Has this problem happened to anyone else? What file would the modRewrite information be in? I checked opi_prodcutimage.php, and it seems like that's where it'd be, but I don't see any code that would implement it. Any help is appreciated. Thanks!

 

Sorry, that's a bug...

 

Just create a php file in admin folder, with the code below. Run that file once and delete it afterward.

 

<?php
//bug no modRewrite

 require('includes/application_top.php');

 if (!defined('OSC_PRODUCT_IMAGE_MODREWRITE')) {
  tep_db_query("INSERT INTO " . TABLE_CONFIGURATION . " (configuration_title,configuration_key,configuration_value,configuration_description,configuration_group_id,sort_order,date_added, set_function) VALUES ('OPI: mod_rewrite enabled', 'OSC_PRODUCT_IMAGE_MODREWRITE', 'true', 'OsC Product Image Module: If mod_rewrite enable, set to true. Otherwise, set to false. <br />', '4', '264', NOW(), '" . tep_db_input("tep_cfg_select_option(array('true', 'false'), ") . "')");
 }

 require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

Edited by Parikesit

Share this post


Link to post
Share on other sites

I may have missed something, but the front of store thumbnails are using the big original sized images uploaded and this is making the front page of the store take a long time to load. Is there a way of making the thumbnails of the front end of the store use the images/_thumbnail_/adminthumb images?

 

Many thanks.

Share this post


Link to post
Share on other sites

I may have missed something, but the front of store thumbnails are using the big original sized images uploaded and this is making the front page of the store take a long time to load. Is there a way of making the thumbnails of the front end of the store use the images/_thumbnail_/adminthumb images?

 

Many thanks.

Managed to solve this. The auto generated images didn't appear on the frontend of the store because I had another add-on which interfered with the OPI auto generator.

Thanks again for OPI.

Share this post


Link to post
Share on other sites

Thanks you for such a great contribution to Oscommerce. This is a very beautiful interface and I love the way it works. I followed all the instructions and went into the Categories and explored a few of my previously added products. It populated all of the pictures as I had expected. I went to add a new product and it added all of the pictures that I asked it too. However, when I went to my store's product page Only one picture was showing. I had added five so I was confused. I added another product with this same result. I then went to add a picture to an existing product page and the picture did not show up. I am confused. Please help!

 

Thanks for your Time.

Share this post


Link to post
Share on other sites

Hello,

 

I need some help, I have installed this ok so far.

 

But when I go to upload a image it just sits there loading.

 

In the server logs I am getting a PHP Fatal error: Call to undefined function json_encode() error.

 

I am running PHP 5.2 but the tech does not want to upload encase it breaks Ensim.

 

I am running osCommerce Online Merchant v2.3.1 as well.

 

I need to find away to get this working as it needs to have multiple images per product.

 

Can any one help please.

 

Thank you.

Share this post


Link to post
Share on other sites

Hi zaenal!

Nice job, your mod is very effective thanks a lot.

I use it on my store and it works very fine..

But... ;)

I have a very large catalog and a lot of images.

Browsing all the image directory is very long time and find the good picture is a challenge.

However I solve this problem by create automaticly subdir in the 'products' directory named like the products_model.

It Works.

But now I need to reduce the start directory browsing in the right directory : images/products/products_model/

I tried to push the new 'relative_dir' to the class but whithout effect.

How could I define the relative_dir different in each page edit product ?

 

I would to get the 'products/products_model/' folder as the base directory to browse and target to uoload new file different for each product.

 

If you could help me You save me :)

 

Thanks again

Share this post


Link to post
Share on other sites

This is the best image addon I have tried during my soon 10 years experience with Oscommerce.

I have all up and running, looks great, but one thing thats concers me is the admin part isnt fully working if you use Internet Explorer 9.

 

The process in Google Chrome or Mozilla Firefox is like this:

Click on Upload Image -> Choose File -> Select Picture -> Click on Upload -> Upload bars shows -> The picture saves

 

The process in Internet Explorer 9 is like this:

Click on Upload Image -> Choose File -> Select Picture -> Click on Upload -> Upload bars shows -> The "select picture" window showes again -> Re select the picture -> the upload bars shows, and just loading. The picture isnt saved.

 

Why does it works in mozilla, google chrome and not in IE9?

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

×