17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1406 Views |
-
linking to resized images....

22 November 2007 at 11:45pm
Hi Folk
I have a page with an image. In the templates I can write
$Pic1.SetWidth(147), which creates the image at 147pixels wide
I can write <a href="$Pic1.URL">see picture</a>, which links through to the image. However, I am not sure how I can link through to a resized image. Is that possible? I want people to see the image at different sizes - something like<a href="$Pic1.SetWidth(800).URL">open a 800x600 picture</a>
How do I do that and do I need to pre-create the images at the desired sizes?
Thank you
Nicolaas
-
Re: linking to resized images....

23 November 2007 at 9:40am
I have done this:
class DesktopItemsPage extends Page {
...
static $has_one = array(
'Pic1' => 'Image',
);
...
}class DesktopItemsPage_Controller extends Page_Controller {
}
class Desktop_Image extends Image {
static $db = null;function generateDesktopSmall($gd) {
$gd->setQuality(90);
return $gd->paddedResize(800,600);
}
function generateDesktopMedium($gd) {
$gd->setQuality(90);
return $gd->paddedResize(1024,768);
}
}my template looks as follows (note that it uses child pages that each have a desktop stored in them as an image...). Thus, the actual page you are on is not a desktopItemsPage but a desktopPage.
<% control Children %>
<div class="desktop">
$Pic1.SetWidth(147)
<a href="$DesktopSmall.URL">800x600</a>
<a href="$DesktopMedium.URL">1024x768</a>
<a href="$Pic1.URL">1280x1024</a>
</div>
<% end_control %>This does not seem to work (there are no links to small and medium image). Then I changed
'Pic1' => 'Image',
to
'Pic1' => 'Desktop_Image',
But that was even less successful - image was lost in its entirety.Where am I going wrong?
Thank you
Nicolaas
| 1406 Views | ||
|
Page:
1
|
Go to Top |
