0

i have to open image in new browser window, but with a larger size.

i am using the code below :

<a href="<?php echo $prodata['Product']['imgurl1'];?>" target="_blank">

 <img src="<?php  echo $data['Product']['imgurl'];?>" alt="Img 1" width="374" height="279" id="bigimage" title="<?php  echo $prodata['Product']['img1desc'];?>" style="border:1px solid #CCCCCC"/>
</a>  

The problem is that the image i need to open in a new browser window should of a lager size.

Can anybody help me, please.?

Can anybody tell me how can i use timthumb with cakephp

satish
  • 111
  • 11

2 Answers2

0

See this answer: (using standard PHP)

 $source_image = imagecreatefromjpeg('/image/path.jpg'); // Open the image
 $source_imagex = imagesx($source_image);
 $source_imagey = imagesy($source_image);

 $dest_imagex = 300; // New size
 $dest_imagey = 200;

 $image2 = imagecreatetruecolor($dest_imagex, $dest_imagey);
 imagecopyresampled($image2, $source_image, 0, 0, 0, 0,
 $dest_imagex, $dest_imagey, $source_imagex, $source_imagey);

 imagejpeg($image2, '/new/image.jpg', 100); // Save the new Image    

You can replace jpeg with png or whatever supported by php.

If you link directly to the image, the browser will display it in original size.

Community
  • 1
  • 1
gamag
  • 423
  • 5
  • 14
  • yes, gamag you are right but how can display it with a larger size in browser. – satish May 27 '13 at 13:51
  • 1) upload a larger image, 2) change the link to the larger image. This has nothing to do with CakePHP, or even PHP. Its just simple HTML – dogmatic69 May 27 '13 at 17:04
  • what i want to know is ---- is there any way to change the height and width of the image by either using cakephp or php or is there any plugin to manipulate the image. Because want to do this with current image only don't have any larger image. – satish May 27 '13 at 17:48
0

You can format your CakePHP code for displaying linked Image like this:

echo $this->Html->link(
$this->Html->Image(
    $data['Product']['imgurl'],
    array(
        'alt'    => 'Img 1',
        'width'  => '374',
        'height' => '279',
        'id'     => 'bigimage',
        'title'  => $prodata['Product']['img1desc'],
        'style'  => 'border:1px solid #CCCCCC',
    )
),
$proddata['Product']['imgurl1'],
array('target' => '_blank')

);