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   1083 Views

Avatar
Iussu

Community Member, 2 Posts

19 June 2009 at 6:51am

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

Community Member, 215 Posts

19 June 2009 at 11:01am

Try:

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

Avatar
Ben Gribaudo

Community Member, 181 Posts

19 June 2009 at 11:53pm

Hi Iussu,

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

Ben

Avatar
Iussu

Community Member, 2 Posts

23 June 2009 at 2:46am

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

Community Member, 181 Posts

24 June 2009 at 7:23am

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

Community Member, 712 Posts

24 June 2009 at 9:23am

Do you try:

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

Avatar
teejay

Community Member, 63 Posts

28 January 2010 at 8:59pm

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 %>