I ran accross a snippet at ssbits and I extended the snippet to to create a lightbox enabled image link in my page.ss. I have not tested this with lightbox installed but I am pretty confident this would work for lightbox and with some adaptation this should work for any other lightbox-clone:
<% control MyImage %>
<% control SetHeight(600) %>
<a href="$URL" rel="lightbox">
<% end_control %>
<% control CroppedImage(580, 200) %>
<img src="$URL" />
<% end_control %>
</a>
<% end_control %>
this results in:
<a href="/s/assets/Uploads/_resampled/SetHeight600-myimage.jpg" rel="lightbox">
<img src="/s/assets/Uploads/_resampled/croppedimage580200-myimage2.jpg" />
</a>
I have three questions:
- Is there any reason why I should not do this? I know there is also the option of adding gd functions to the page.php, so is there any reason I should be using that instead?
- The author gave these other possiblities for controling the image: CroppedImage(w,h), PaddedImage(w,h), ResizedImage(w,h), control SetWidth(w), control SetHeight(h). These should be documented in the gd api documentation, but I can not find them. Where can I find out about these methods, and are there more?
- I noticed I can use $Title to get the name of the image, and in this way I would be able to use the name as a title and alt attribute. However I can only use it inside the first control statement (control MyImage). Are there any other variables like that, that I can use?