Page 1 of 1
Link (php echo) to the original image file
Posted: Tue Aug 28, 2012 9:07 pm
by SimonHavelock
Hi!
Quick problem: how can I get link to the original file that was uploaded that is located in data folder not in cache/data?
<?php echo -?- ?>
Cheers!
Re: Link (php echo) to the original image file
Posted: Wed Aug 29, 2012 2:15 am
by oc-extensions
Hi,
Depends where you want to use:
example: if product page (controller) you can use:
Code: Select all
$image = HTTP_IMAGE . $product_info['image'];
Re: Link (php echo) to the original image file
Posted: Thu Aug 30, 2012 12:31 am
by SimonHavelock
Thanks for your reply.
I need it for product.tpl, because changes I introduced in product.php only made it worse
How can I do that?
My problem is that I'm implementing zoom jquery plugin and I need 3 sizes for additional images (now there are two: thumb and popup). And I need original url for zoom image

Re: Link (php echo) to the original image file
Posted: Thu Aug 30, 2012 12:38 am
by oc-extensions
Hi,
in controller/catalog/product.php find
Code: Select all
if ($product_info['image']) {
$this->data['popup'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
} else {
$this->data['popup'] = '';
}
and change to :
Code: Select all
if ($product_info['image']) {
$this->data['popup'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
$this->data['original_image'] = HTTP_IMAGE . $product_info['image'];
} else {
$this->data['popup'] = '';
$this->data['original_image'] ='';
}
Re: Link (php echo) to the original image file
Posted: Thu Aug 30, 2012 1:38 am
by SimonHavelock
Thanks! I'm getting closer
However now it's showing me original image of product not additional original image.
Code: Select all
if ($product_info['image']) {
$max_width = (int)315;
$max_height = (int)900;
$oldsize = getimagesize(DIR_IMAGE.$product_info['image']);
$scale = min($max_width/$oldsize[0], $max_height/$oldsize[1]);
$new_width = ceil($scale*$oldsize[0]);
$new_height = ceil($scale*$oldsize[1]);
$this->data['popup'] = $this->model_tool_image->resize($product_info['image'], $new_width , $new_height);
$this->data['original_image'] = HTTP_IMAGE . $product_info['image'];
} else {
$this->data['popup'] = '';
$this->data['original_image'] ='';
}
And I put this into my product.tpl file:
Code: Select all
<?php if ($images) { ?>
<div class="image-additional">
<?php foreach ($images as $image) { ?>
<a href="<?php echo $original_image ?>" title="<?php echo $heading_title; ?>" class="cloud-zoom-gallery" rel="useZoom: 'zoom', smallImage: '<?php echo $image['popup']; ?>' "><img src="<?php echo $image['thumb']; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" /></a>
<?php } ?>
</div>
<?php } ?>
It's possible that I need to change something here, but I have no idea what to add:
Code: Select all
foreach ($results as $result) {
$this->data['images'][] = array(
'popup' => $this->model_tool_image->resize($result['image'], $new_width_pop , $new_height_pop),
'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_additional_width'), $this->config->get('config_image_additional_height'))
);
Re: Link (php echo) to the original image file
Posted: Fri Aug 31, 2012 12:08 am
by oc-extensions
Code: Select all
foreach ($results as $result) {
$this->data['images'][] = array(
'popup' => $this->model_tool_image->resize($result['image'], $new_width_pop , $new_height_pop),
'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_additional_width'), $this->config->get('config_image_additional_height')),
'original' => HTTP_IMAGE . $result['image']
);
Re: Link (php echo) to the original image file
Posted: Fri Aug 31, 2012 1:43 am
by SimonHavelock
Thanks! It works perfectly.
I had to change this fragment, though.
Code: Select all
<?php if ($images) { ?>
<div class="image-additional">
<?php foreach ($images as $image) { ?>
<a href="<?php echo $image['original_image'] ?>" title="<?php echo $heading_title; ?>" class="cloud-zoom-gallery" rel="useZoom: 'zoom', smallImage: '<?php echo $image['popup']; ?>' "><img src="<?php echo $image['thumb']; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" /></a>
<?php } ?>
</div>
<?php } ?>