I'm trying to build a custom function which returns the URL of a resized image..
The deal is that I'm going to have a series of thumbnail images listed on the page, each of which will link to a larger version of the image. I don't want the linked to image to be the full size image, however, as this is likely to be too large, so I wanted to provide a link to a resized image.
(Following me so far?)
Right now the code in my template looks like this:
<% if $Photos %>
<ul class="project-photos">
<% loop $Photos %>
<li><a href="{$URL}">{$CroppedImage(210,210)}</a></li>
<% end_loop %>
</ul>
<% end_if %>
what I was planning on changing the `{$URL}` to something like `{$croppedURL(610)}`, and having a function on my Photo class (which extends the Image class) which returned the resized the URL, figuring I would do something like this:
public function croppedURL($width = false) {
if ($width != false) {
$this->resizeByWidth($width);
}
return $this->URL();
}
But upon doing so, I get a Server Error 500.
I'vee tried my best to make this work following the examples found on http://doc.silverstripe.org/framework/en/reference/image - but thus far I've not had any luck - can someone help please?
Thank you :)