Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Image as link


Reply

7 Posts   1076 Views

Avatar
Iussu

19 June 2009 at 6:51am Community Member, 2 Posts

I have a uploadable image that apears on the page. I want to make it a clickable link so i went about and tried

$NewProduct.SetHeight(150).URL

to get the path of the image resized.

But that makes the image not show up at all. Am I missing something very easy?

Thanks in advanced.

Avatar
Howard

19 June 2009 at 11:01am Community Member, 215 Posts

Try:

<a href="$NewProduct.URL">$NewProduct.SetHeight(150)</a>

Avatar
Ben Gribaudo

19 June 2009 at 11:53pm Community Member, 181 Posts

Hi Iussu,

Do you want to link to the full-sized original or a resized derivative?

Ben

Avatar
Iussu

23 June 2009 at 2:46am Community Member, 2 Posts

Sorry for getting back late, howard thanks, that solved one part of my new probelms.

Ben, my main issue is that I am trying to get Lightbox to work. I am new to this and I cannot find anything that tells me how to code it so i can easily just grab the URL to make it work with Lightbox. Any info on where i can look to get info would help.

Avatar
Ben Gribaudo

24 June 2009 at 7:23am Community Member, 181 Posts

Hello,

Due to irregularities in how the current template parser works, $NewProduct.SetHeight(150).URL is invalid syntax. To achieve the desired effect, you could define a method in your page's class that returns the URL you want (something like " return $this->NewProduct->SetHeight(150)->URL").

Ben

Avatar
Hamish

24 June 2009 at 9:23am Community Member, 712 Posts

Do you try:

<% control NewProduct.SetHeight(150) %>
   <a href="$URL">$Tag</a>
<% end_control %>

Avatar
teejay

28 January 2010 at 8:59pm Community Member, 63 Posts

How would u do it for this case ??

<% control Images %>

   <a href="$ImageResource.URL" rel="shadowbox[$StallionID]">
      <% control ImageResource %>
         <% control CroppedImage(150, 115) %>
         <img src="$URL" title="$Top.Title" alt="$Top.Title" />
         <% end_control %>
      <% end_control %>
   </a>

<% end_control %>