Post by Giraffe » Sun Dec 21, 2008 8:21 am

Hi Everyone i have small problem with changing size of the product image only on product page.
1. I know that from admin i can change the size for all thumb pictures.
2. But how to make bigger images only on the product page and i am not talking about additional images section....
3. can anyone explain to me where $thumb variable is defined as i made search in almost all php files but i cannot find $thumb declaration...????

now the code:

I know that product.php is the file responsible for displaying product information on the screen and product.tpl is the template for it which says:

Code: Select all

  <div id="product">
    <div class="a"><a href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>" class="thickbox"><img src="<?php echo $thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>"></a><br>
      <?php echo $text_enlarge; ?></div>
now in this bit taken from product.tpl i see that path for the image is taken from the variable called $thumb
now i want open cart to:
1. Prepare for me medium sized image
2. generate for it path that will be stored in $medium variable which i can call in this place and simply have the code like this:

Code: Select all

  <div id="product">
    <div class="a"><a href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>" class="thickbox"><img src="<?php echo $medium; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>"></a><br>
      <?php echo $text_enlarge; ?></div>
anyone please help...

(I am runing Opencart 0.7.9 RC4)

User avatar
New member

Posts

Joined
Tue Dec 09, 2008 4:40 am

Post by bthirsk » Sun Dec 21, 2008 10:23 am

It is /catalog/controller/product.php that you do this.

Line 88
  $view->set('thumb', $image->resize($product_info['filename'], $config->get('config_image_width'), $config->get('config_image_height')));

change to:

  $view->set('thumb', $image->resize($product_info['filename'], 250, 250));

You just specify whatever size you want.

Brent


Active Member

Posts

Joined
Wed Sep 03, 2008 11:33 am
Location - Canada

Post by Giraffe » Sun Dec 21, 2008 7:09 pm

hmm that would be right!
SO because i finally get it i will share my code :)

thanks!

So to sum it all up
product.php

before:

Code: Select all

$view->set('thumb', $image->resize($product_info['filename'], $config->get('config_image_width'), $config->get('config_image_height')));
after:

Code: Select all

$view->set('thumb', $image->resize($product_info['filename'], 150, 200));
where 150 is width and 200 is a height of a main product image

in that case we don't touch the product.tpl

And now for example If someone wants to have different size of additional pictures then He can modify code in product.php

before:

Code: Select all

foreach ($results as $result) {
        		$image_data[] = array(
          			'title' => $result['title'],
          			'popup' => $image->href($result['filename']),
          			'thumb' => $image->resize($result['filename'], $config->get('config_image_width'), $config->get('config_image_height')),
          		);
      		}
      		$view->set('images', $image_data);
after:

Code: Select all

foreach ($results as $result) {
        		$image_data[] = array(
          			'title' => $result['title'],
          			'popup' => $image->href($result['filename']),
          // notice below line changes where 150 is a width and 200 is height of a additional image
          			'thumb' => $image->resize($result['filename'], 150, 200)),
          		);
      		}
      		$view->set('images', $image_data);
That's it!
Last edited by Giraffe on Sun Dec 21, 2008 7:12 pm, edited 1 time in total.

User avatar
New member

Posts

Joined
Tue Dec 09, 2008 4:40 am
Who is online

Users browsing this forum: No registered users and 3 guests