Forums / All Other Contributions/Addons / Jquery Zoom [Support thread]

Jquery Zoom [Support thread]

Started by yellow1912 on 3 Jan 2009, 8:26 PM · Views: 82,425

Results 281 to 300 of 385
7 Feb 2013, 9:22 AM
#281
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Jquery Zoom [Support thread]

grr excuse the extra post, wont let me edit the previous.. missed off the "px" in the style...


ok not tested and not got much time to spend on this today, however hopefully you should see the logic here and be able to have a play, if it works first time i'll be chuffed..

in includes/templates/YOUR_TEMPLATE/templates/tpl_modules_main_product_images.php

replace this:

[/<script language="javascript" type="text/javascript"><!--
document.write('<?php echo '<a href="' . $products_image_large . '" class="bonzer_zoom" rel="product_info">' . zen_image(addslashes($products_image_medium), addslashes($products_name), MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '</a>'; ?>');
//--></script>PHP]

with this:

[PHP]    <script type="text/javascript">
      function func (img) {
        if(img.height >= img.width) {
          img.style.height = "100%";
          img.style.width = "auto";
        } else {
          img.style.width = "100%";
          img.style.height = "auto";
        }
      }
    </script>

<?php
$iCstart = '<div id="iContainer" style="width:' .MEDIUM_IMAGE_WIDTH. 'px; height:' .MEDIUM_IMAGE_HEIGHT. 'px">';
$iCend = '</div>';
?>

<script language="javascript" type="text/javascript"><!--
document.write('<?php echo $iCstart. '<a href="' . $products_image_large . '" class="bonzer_zoom" rel="product_info"><img onload="func(this);" src="' . $products_image_medium . '" /></a>' . $iCend; ?>');
//--></script>

so heres what we are now doing..
using a clever script to check the image height and width and depending on which is the greatest applying image width 100% to it.

this then should fill to 100% of either the container width or height defined by the admin settings for MEDIUM_IMAGE_WIDTH & MEDIUM_IMAGE_HEIGHT which is now applied with a div around the outside of the image inside the document.write. defined by
$iCstart and $iCend

hope it works... please let me know

Phil Rogers
A problem shared is a problem solved.

7 Feb 2013, 1:51 PM
#282
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

looks liek your all but there?!?! did it work?

Phil Rogers
A problem shared is a problem solved.

7 Feb 2013, 2:05 PM
#283
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

attattched is a working example of the logic that is being applied to the div and image..

notice if in the htlm source code if you chage either the width or height value in either of the divs the image will re-size but maintain aspect ratio.

just wack it in a html file and load on your pc locally to play.

i'll leave you to tinker..


<html> <head> <title>Test page</title> <script type="text/javascript"> function func (img) { if(img.height >= img.width) { img.style.height = "100%"; img.style.width = "auto"; } else { img.style.width = "100%"; img.style.height = "auto"; } } </script> </head> <body>
    <div style="width:300px; height:300px">
      <img  onload="func(this);"  src="http://img.yandex.net/i/www/logo.png"  />
	</div>
    
   <div style="width:300px; height:200px">
      <img onload="func(this);" src="http://t2.gstatic.com/images?q=tbn:ANd9GcROiXx6BaNBDTn4xAS8FBMH7qUZIOPKcXZKL6asl4hHw2ys-h8Z" />
</div> </body> </html>

Phil Rogers
A problem shared is a problem solved.

7 Feb 2013, 3:39 PM
#284
kevin205 avatar

kevin205

Totally Zenned

Join Date:
Dec 2012
Posts:
607
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

I wanted to post this just in case others are stuck and clueless like I was yesterday without help!

It works now using one size image at 72dpi and 800px wide to get the zoom effect.

I had to move the jquery:
from:```php
includes/modules/pages/product_info/"jscript_jquery-1.6.js


to:```php
includes/templates/MyTemplate/jscript/jscript_jquery-1.6.js

And removed the following call for JQuery used in another plugin (this plugin still functions on all pages. The way it meant to work.)

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>

from:```php
includes/templates/MyTemplate/common/tpl_main_page.php


The sequence of uploading the images when you setup and upload your products were as follow: (ie.  if you have four images to upload)
Image1_3.jpg
Image1_2.jpg
Image1_1.jpg
Image1.jpg This being the last and main image for the product.

**Only problem** is that images can only be uploaded to the main image directory, otherwise the code breaks!

Thanking for hard work of Nick, Phil and Chad.

Using Zen Cart 1.5.1

7 Feb 2013, 3:48 PM
#285
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

Kevin205:

It works now using one size image at 72dpi and 800px wide to get the zoom effect.
the image can be any size... however to get the zoom effect the size for your product info image size needs to be set smaller than the actual image size (if only using the one size image or small and medium. if you also use large images, it will use the large image for zooming and medium or small for the product info page main image).

[QUOTE]Only problem is that images can only be uploaded to the main image directory, otherwise the code breaks![/QUOTE
this bug was corrected a few posts back if you read through but the files havent yet been updated.

Thanks for your kind words.. still working hard to make this work for all set-ups to reduce the limitations.

Phil Rogers
A problem shared is a problem solved.

7 Feb 2013, 3:50 PM
#286
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

philip937:

this bug was corrected a few posts back if you read through but the files havent yet been updated.

Thanks for your kind words.. still working hard to make this work for all set-ups to reduce the limitations.

http://www.zen-cart.com/showthread.php?116789-Jquery-Zoom-Support-thread&p=1184215#post1184215

Phil Rogers
A problem shared is a problem solved.

7 Feb 2013, 3:59 PM
#287
kevin205 avatar

kevin205

Totally Zenned

Join Date:
Dec 2012
Posts:
607
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

philip937:

the image can be any size... however to get the zoom effect the size for your product info image size needs to be set smaller than the actual image size (if only using the one size image or small and medium. if you also use large images, it will use the large image for zooming and medium or small for the product info page main image).

Not really. You don't have to that.

I am not using small, medium & large images. Only one image. When it comes to production time, it does not make any sense dealing with all that extra work.

What I have done is to change my "tpl_product_info_display.php" with <div>s limiting the size of the main product image.

Using Zen Cart 1.5.1

7 Feb 2013, 4:06 PM
#288
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

Kevin205:

Not really. You don't have to that.

I am not using small, medium & large images. Only one image. When it comes to production time, it does not make any sense dealing with all that extra work.

What I have done is to change my "tpl_product_info_display.php" with <div>s limiting the size of the main product image.

you've lost me.. I said you can use any image size..

whether or not you are using
a small image
a small and medium image
a small medium and large image

the admin settings for product info image size is what limits the image size. So what I am saying is if you use just a small image lets say

600px x 800px

then so that the "zoom" works, because you do not have a large image you would have to have the product info image size in the admin set to say:

width 300
height 400

if you have the admin setting set to more than

width 600
height 800

then as you do not have a large image for it to use for zoom there would be no zoom.

I am currently working on a fix so that images of different dimensions can still be used and still controlled through the admin so they do not stretch to fit the area of the main image area.

Phil Rogers
A problem shared is a problem solved.

7 Feb 2013, 4:15 PM
#289
kevin205 avatar

kevin205

Totally Zenned

Join Date:
Dec 2012
Posts:
607
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

My Admin for Product Info - Image is set 400px X 400px
My div is set to 400px wide (no height specified)
My image size is 800px wide.

It works for me. I get the effect.

Using Zen Cart 1.5.1

7 Feb 2013, 4:28 PM
#290
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

Kevin205:

My Admin for Product Info - Image is set 400px X 400px
My div is set to 400px wide (no height specified)
My image size is 800px wide.

It works for me. I get the effect.

not sure what you have your DIV for.. it should work without the div..

but yes with those values it should work well :o)

Phil Rogers
A problem shared is a problem solved.

7 Feb 2013, 4:46 PM
#291
kevin205 avatar

kevin205

Totally Zenned

Join Date:
Dec 2012
Posts:
607
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

philip937:

not sure what you have your DIV for.. it should work without the div..

but yes with those values it should work well :o)

I had to re-lay the product info page on this site differently.

Using Zen Cart 1.5.1

7 Feb 2013, 5:13 PM
#292
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

ok its close..

this seems to work, but my end seems a bit intermittent.. not sure if its a caching issue or if there is conflicting java, but having no expreience with java I cant diagnose..

perhaps you guys can play with it and let me know what results you see..

so, as a test replace your
includes/templates/YOUR_TEMPLATE/templates/tpl_modules_main_product_image.php with this code:

<?php
/**
 * Module Template
 *
 * @package templateSystem
 * @copyright Copyright 2003-2011 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_modules_main_product_image.php 18698 2011-05-04 14:50:06Z wilt $
 */
?>
<?php require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_MAIN_PRODUCT_IMAGE)); ?>
<div id="productMainImage" class="centeredContent back">



<?php
$iwidth = MEDIUM_IMAGE_WIDTH . 'px'; 
$iheight = MEDIUM_IMAGE_HEIGHT . 'px'; 
?>

<script language="javascript" type="text/javascript"><!--
      function func (img) {
          img.style.height = "<?php echo $iwidth ?>";
          img.style.width = "<?php echo $iheight ?>";
      }

document.write('<?php echo '<a href="' . $products_image_large . '" class="bonzer_zoom" rel="product_info"><img src="' . $products_image_medium . '" onload="func(this);"  /></a>' ?>');
//--></script>



<noscript>
<?php
  echo '<a href="' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '" target="_blank">' . zen_image($products_image_medium, $products_name, MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>';
?>
</noscript>
</div>

Phil Rogers
A problem shared is a problem solved.

7 Feb 2013, 5:25 PM
#293
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

actually this is more logical

<?php
/**
 * Module Template
 *
 * @package templateSystem
 * @copyright Copyright 2003-2011 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_modules_main_product_image.php 18698 2011-05-04 14:50:06Z wilt $
 */
?>
<?php require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_MAIN_PRODUCT_IMAGE)); ?>
<div id="productMainImage" class="centeredContent back">



<?php
$iwidth = MEDIUM_IMAGE_WIDTH . 'px'; 
$iheight = MEDIUM_IMAGE_HEIGHT . 'px'; 
?>

<script language="javascript" type="text/javascript"><!--

function func (img) {
if(img.height >= img.width) {
img.style.height = "<?php echo $iheight ?>";
img.style.width = "auto";
} else {
img.style.width = "<?php echo $iwidth ?>";
img.style.height = "auto";
}
}


document.write('<?php echo '<a href="' . $products_image_large . '" class="bonzer_zoom" rel="product_info"><img src="' . $products_image_medium . '" onload="func(this);"  /></a>' ?>');
//--></script>



<noscript>
<?php
  echo '<a href="' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '" target="_blank">' . zen_image($products_image_medium, $products_name, MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>';
?>
</noscript>
</div>

still very intermittent for me, very weird.. maybe doesn't like some of my images?

Phil Rogers
A problem shared is a problem solved.

7 Feb 2013, 5:43 PM
#294
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

Guys,

Here is the latest fileset with some bug fixes and includes the images to display correctly if using different image sizes and maintians the ability to set image size in the admin for the product info image.

The image size part is still a bit flakey and needs more testing and feedback.

Still need to wrap the additional product image links inside <script> document.write so that they are not displayed when Javascript is disabled.

Let me know how you get on, I don't have much more I can give on this right now so maybe someone else would like to take charge? :P

Attachment #11904

Cheers

Phil

Phil Rogers
A problem shared is a problem solved.

7 Feb 2013, 6:58 PM
#295
chadderuski avatar

chadderuski

Totally Zenned

Join Date:
Apr 2006
Location:
Dark Side of the Moon
Posts:
986
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

Hey Philip,

Will try your latest package shortly... thanks for the REALLY hard work :P

I tried the previous post's code, and its VERY close. Some images (ones I have as solo images, but in a sub-directory inside /images)
are either showing FULL size.

But others (I have a number of different ways to do images upload here), work well, and the main image window re sizes to fit the proportion of the clicked image.

Click through this folder to see some of the different results. Will try your new file set shortly:

http://96 .30 .58.67/index.php?main_page=index&cPath=6_110

-chadd

ps: we should probably start putting beta version numbers on these file sets so people don't get them mixed up :p

7 Feb 2013, 7:06 PM
#296
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

@chadd
Glad to be of help, just hope it works or at least is almost there. In theory the new fileset should allow your admin settings for product info image to determine the width and height but "should" still retain aspect ratio.

Let me know if it works. My post from this morning wasn't working hence why I changed the method in the new files.

Phil Rogers
A problem shared is a problem solved.

7 Feb 2013, 7:11 PM
#297
chadderuski avatar

chadderuski

Totally Zenned

Join Date:
Apr 2006
Location:
Dark Side of the Moon
Posts:
986
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

Philip!

Go look at the above link and you'll see it's quite close. Only thing breaking is the solo images that are really big (don't know why yet). Wanted you to know.

We (strangely enough) had that working before. Zencart was sizing my HUGE image to fit in the prescribed products image dimentions. Now I am getting the full sized image.

investigating...

-chadd

7 Feb 2013, 7:26 PM
#298
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

Are you on the latest file set now?

Phil Rogers
A problem shared is a problem solved.

7 Feb 2013, 7:30 PM
#299
chadderuski avatar

chadderuski

Totally Zenned

Join Date:
Apr 2006
Location:
Dark Side of the Moon
Posts:
986
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

yes. latest file set.

Here's what I found for the inconsistency:

If a product HAS additional images, it's working.

If there are NO additional images, it seems to be breaking...

EDIT:

ALSO, it seems that once of the attributes is pulling from the previous image...

7 Feb 2013, 7:32 PM
#300
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Jquery Zoom [Support thread]

When I'm looking its really hard to see if its working. Can you set your product info image size in the admin to say 50 wide 50 high?

Phil Rogers
A problem shared is a problem solved.