3214 Posts in 848 Topics by 810 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1438 Views |
-
How to get image orientation in template?

7 November 2009 at 11:38am
I need somethig like this:
<% if Photo.Orientation == 1 %>
$Photo.$SetHeight(200)
<% else_if %>
$Photo.$SetWidth(200)
<% end_if %>Dont work!
Can anybody help me?
-
Re: How to get image orientation in template?

7 November 2009 at 11:33pm
Hi!
I don’t know where this Orientation propriety is coming from (I guess you added it to the Photo class) but your code will never work if you don’t remove the $ before SetHeight and SetWidth.
Hope it helps,
Juan -
Re: How to get image orientation in template?

8 November 2009 at 12:20am
$Image.Orientation - It's a SilverStripe property ( http://doc.silverstripe.org/doku.php?id=image ).
It returns 1 if image vertical, and 2 - if horizontal. And I can't work with this values in my template, like this<% if Photo.Orientation == 1 %>
$Photo.SetHeight(200)
<% else_if %>
$Photo.SetWidth(200)
<% end_if %>and Photo:
static $has_one = array(
'Photo' => 'Image'
); -
Re: How to get image orientation in template?

8 November 2009 at 1:27am
One '=' in you comparison statement!
<% if Photo.Orientaion = 1 %>
....
<% else %>
....
<% end_if %> -
Re: How to get image orientation in template?

8 November 2009 at 2:13am
Still don't work!
And in SS templates for comparision use ==
(http://doc.silverstripe.org/doku.php?id=templates&s=property) -
Re: How to get image orientation in template?

8 November 2009 at 10:08am
Nope. It's = in templates (not ==).
Maybe try the following:<% control Photo %>
<% if Orientation = 1 %>
$SetHeight(200)
<% else_if %>
$SetWidth(200)
<% end_if %>
<% end_control %> -
Re: How to get image orientation in template?

8 November 2009 at 11:53pm
Thank you, banal! It works!
This is full working code:
<% control Photo %>
<% if Orientation = 1 %>
$SetHeight(200)
<% else %>
$SetWidth(200)
<% end_if %>
<% end_control %>
| 1438 Views | ||
|
Page:
1
|
Go to Top |



