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 } ?>