Page 1 of 1
Creating a Mid-Size Product Image (In adddition to 'thumb' and 'popup')?
Posted: Sun Sep 28, 2008 5:54 am
by kristin558
Hi Everyone, I'm brand new here as of today. Have search the forums for answers to my question but w/o luck. Hoping someone out there can offer some advice.
I want to be able to have my thumbs resized to 100x150 (already set in the admin panel, no prob) and have my pop ups for text_enlarge to be full size (300x450)--also no problem. BUT, now my hope is to be able to create a middle size image--150x250 for the product pages. In other words, make the main product image visually dominant on the page (and add'l image thumbs smaller/subordinate), but not so big as the pop ups, because that pushes the add'l images down and wastes screen space.
If it helps, here's a visual (
http://www.betsyhendersondesigns.com/sh ... duct_id=12) Note: the main product image is currently at popup size.
I've tried a few things on my own w/o luck, but thought I'd better ask the friendly pros for help before I destroy all my progress! Thanks in advance

Re: Creating a Mid-Size Product Image (In adddition to 'thumb' and 'popup')?
Posted: Sun Sep 28, 2008 7:27 am
by bruce
The following snippet is from the Featured/Latest contribution and shows how to create an image of a specific size. In this case the size set in the admin. I have added an extra definition "midsize" to show you.
Code: Select all
foreach ($results as $result)
{
//$desc = implode(' ',array_slice(preg_split('/\s/',substr($result['description'],3)),0,30));
$desc = $result['description'];
//if (strlen($desc) < strlen($result['description'])) { $desc.= ' ...'; }
$product_data[] = array(
'name' => $result['name'],
'desc' => $desc,
'href' => $url->href('product', FALSE, array('product_id' => $result['product_id'])),
'thumb' => $image->resize($result['filename'], $config->get('config_image_width'), $config->get('config_image_height')),
'midsize' => $image->resize($result['filename'], 150, 250),
'price' => $currency->format($tax->calculate($result['price'], $result['tax_class_id'], $config->get('config_tax')))
);
}
$view->set('products', $product_data);
And in the template code as shown below, you can reference the image as $product['midsize'] instead of, or as well as $product['thumb']
Code: Select all
<?php if ($products) { ?>
<p class="heading"><?php echo $heading_title; ?></p>
<table style="width:100%;">
<?php foreach ($products as $product) { ?>
<tr class="">
<td style=""><a href="<?php echo $product['href']; ?>">
<img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>"
alt="<?php echo $product['name']; ?>" /></a></td>
<td><b><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></b> - <?php echo $product['desc']; ?></td>
<td><?php echo $product['price']; ?></td>
</tr>
<?php } ?>
</table>
<?php } ?>
Re: Creating a Mid-Size Product Image (In adddition to 'thumb' and 'popup')?
Posted: Tue Dec 09, 2008 7:19 am
by Giraffe
Hi Everyone
First I want to congratulate you guys for great ecommerce software!
I have a problem with getting mid size image to work in latest version of opencart....
I cannot seem to locate bits of code that this thread relates to...
any help?
Re: Creating a Mid-Size Product Image (In adddition to 'thumb' and 'popup')?
Posted: Tue Dec 09, 2008 7:52 am
by bthirsk
This was from a great contribution
http://www.opencart.com/contribution/in ... tion_id/27
You can add the same thing in your products as Bruce has explained here, if that's what you want.
Just look for the code
$image->resize($result['filename'], $config->get('config_image_width'), $config->get('config_image_height')),
This is where your main image is defined.
Re: Creating a Mid-Size Product Image (In adddition to 'thumb' and 'popup')?
Posted: Tue Dec 09, 2008 7:57 am
by Giraffe
Cheers!
Re: Creating a Mid-Size Product Image (In adddition to 'thumb' and 'popup')?
Posted: Wed Dec 10, 2008 8:17 pm
by Jacob
Hello
I have basic knowledge in PHP, and am struggling to follow here, could someone please provide the file directories for both bits of bruces code?
Also I have downloaded the contrib but am not sure which of these 'Latest Products Added' or
'Featured Products' I need to use? Is there a thread discussing this contrib? I don't want to make any disastrous errors!
I basically want to change the home page image size/position/spacing to resemble the attachment.
Thank you
Re: Creating a Mid-Size Product Image (In adddition to 'thumb' and 'popup')?
Posted: Wed Dec 10, 2008 10:33 pm
by Jacob
So first all of all, I have a back up so can amend anything that goes wrong, I hope!
Contribution: "Featured_Latest_Special_Products_v1.0"
My check list:
If you wish to INSTALL the "Featured Products" item ONLY then DELETE the following files :
Yes I did this.
MODIFY the products files [/controller/product.php: /language/english/product.php: /template/default/content/product.tpl: to remove references to "Special_Offer".:
Yes I did this.
MODIFY add_ columns to_product.sql to read :
Yes I did this.
------------------------------------------------------------------------------------------------------------
INSTALL:
Copy the files in the directories below "Featured_Latest_Special_Products_v1.0" preserving the folder structure !
I used the 'Copy to' Windows option, and copied each file to it's corresponding web folder directory and uploaded to live site.
Attention!
Ensure that the date in the language folders and template folders that you use are updated !
Did not understand this!
Use the file "add_columns_to_product.sql" to add the necessary columns for featured and special offer products in the product table in your database.
Not sure about this either, I uploaded it same as the other files e.g. admin/add_columns_to_product.sql.
To install the module : Go to Extensions -> Module
> Select Insert
Yes did this bit, but got this page:
Error: Unknown column 'featured' in 'field list'
Error No: 1054
To avoid getting "Permission Denied" errors when installing the module(s)
Followed instructions and got this page:
Error: Language file /usr/www/support/capoeiracanal/www/upload/admin/language/english/controller/module_catalog_featured.php not found!
So looks like the files are not in the right places? Please help
Re: Creating a Mid-Size Product Image (In adddition to 'thumb' and 'popup')?
Posted: Wed Dec 10, 2008 11:15 pm
by jty
I'm not familiar with this contribution but here is your mistake or one of them
Use the file "add_columns_to_product.sql" to add the necessary columns for featured and special offer products in the product table in your database.
Not sure about this either, I uploaded it same as the other files e.g. admin/add_columns_to_product.sql.
sql files are not to be uploaded. They are sql files that need to be run against your database to add fields, amend them, insert data etc into your database.
Run that sql file against your database using phpmyadmin
Backup your database first incase you need to rollback. You can do this in Open Cart admin with the back-up feature or I use phpmyadmin to backup my database.
Re: Creating a Mid-Size Product Image (In adddition to 'thumb' and 'popup')?
Posted: Thu Dec 11, 2008 1:42 am
by Qphoria
The problem you are having is a mix of our non-maintainable downloads area, and the incorrect usage of uploading only patches of files for later versions of this contrib.
This contrib is a nightmare because too many hands are in the cookie jar, all doing things differently
I've reached my hand into the jar and did a proper upgrade (says me!)
You can find it here:
http://forum.opencart.com/index.php/top ... l#msg12470
Re: Creating a Mid-Size Product Image (In adddition to 'thumb' and 'popup')?
Posted: Thu Dec 11, 2008 2:51 am
by Jacob
Thanks, so before I do anything else, I have version opencart_v0.7.8 installed, do I need the contribution? In the home.tpl file I have an option to show 'Latest Products'.
Code: Select all
<div class="heading"><?php echo $heading_title; ?></div>
<?php echo $text_greeting; ?>
<div class="heading"><?php echo $text_latest; ?></div>
<?php foreach ($products as $product) { ?>
<div class="products"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>"></a><br><b><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></b><br><?php echo $product['price']; ?></div>
<?php } ?>
But as I said, I have no idea how to change the image size,position etc. By installing the 'proper upgrade' will I then be able to achieve the look in my attachment?
Thanks again
Re: Creating a Mid-Size Product Image (In adddition to 'thumb' and 'popup')?
Posted: Thu Dec 11, 2008 2:55 am
by Qphoria
Well you'd be better off upgrading to 0.7.9 first.
You could probably use the updated version of the contrib if you change all references to from "request->gethtml" to "request->get"
But looking at your original post. I don't think this is what you want. You simply want to add a big picture on the homepage like the image you attached. You don't need this contrib at all.
Just edit the original /catalog/template/default/content/home.tpl page and remove the whole products section and just use simple html to add an image
Re: Creating a Mid-Size Product Image (In adddition to 'thumb' and 'popup')?
Posted: Thu Dec 11, 2008 3:01 am
by Jacob
But looking at your original post. I don't think this is what you want. You simply want to add a big picture on the homepage like the image you attached. You don't need this contrib at all.
Well I would like to know how to change the size of the images, though that attachment is not meant to show one big picture, but actually separate images/products that are also links.
Re: Creating a Mid-Size Product Image (In adddition to 'thumb' and 'popup')?
Posted: Thu Dec 11, 2008 3:04 am
by Jacob
Sorry, missed the last bit of your reply, so I can just use html in the home.tpl to design the home page? .. oh ok!
Re: Creating a Mid-Size Product Image (In adddition to 'thumb' and 'popup')?
Posted: Thu Dec 11, 2008 3:24 am
by Qphoria
Well, depending what you want.
If you want something like
http://www.bestbuy.com/
Where the main section is custom images and flash announcing sales and deals and stuff that you make and update as you like. then you dont need the contrib. Just edit the /catalog/template/default/content/home.tpl file and put your stuff there in normal html
If you want products dynamically loaded from the database in different sizes, then you would need to use the contrib and edit the:
/catalog/template/default/module/featured.tpl file and customize it with tables and stuff in html and a mix of php calls to products from the database. But that takes a bit more advanced coding
Re: Creating a Mid-Size Product Image (In adddition to 'thumb' and 'popup')?
Posted: Thu Dec 11, 2008 3:35 am
by Jacob
Got you!
I can see the advantage of using the data base and will strive to attempt this.
Cheers
Re: Creating a Mid-Size Product Image (In adddition to 'thumb' and 'popup')?
Posted: Thu Dec 11, 2008 5:42 am
by Jacob
... Me again, can't for the life of me do the simple thing of adding an image
Just edit the original /catalog/template/default/content/home.tpl page and remove the whole products section and just use simple html to add an image
I think the problem is the path, I created a new image folder within the content folder added an image to it, then added the html to the home.ptl file like so:
Code: Select all
<img src="image/test.png" alt="blah" title="blah" width="394" height="260"/>
But no image is displayed, I tried using the the original image folder counting how many folders the path went up like so:
four folders up then image
Code: Select all
<img src="......../image/class22.png" alt="blah" title="blah" width="394" height="260"/>
</div>
Re: Creating a Mid-Size Product Image (In adddition to 'thumb' and 'popup')?
Posted: Thu Dec 11, 2008 5:51 am
by Qphoria
When in doubt, just use the full path.. worry about relativing it later
Re: Creating a Mid-Size Product Image (In adddition to 'thumb' and 'popup')?
Posted: Thu Dec 11, 2008 6:10 am
by Jacob
...Well that works
Thank you Qphoria