how can I get calculate with image height and width? I am trying to center an image like described in the first answer:
How to make an image center (vertically & horizontally) inside a bigger div
That's what I have tried so far:
<% control ProfileImage %>
<% if getOrientation = 1 %>
<img src="$URL" style="margin-left: -{$Width/2)}px" class="portrait"/>
<% else_if getOrientation = 2 %>
<img src="$URL" class="landscape"/>
<% end_if %>
<% end_control %>
The output of the decisive line is:
<img src="/assets/Uploads/picture.jpg" style="margin-left: -{154/2)}px" class="portrait"/>
Then I tried to write an own function:
class Profile extends Page{
//...
function GetHalfWidth(){
return ($this->ProfileImage->Width)/2;
}
//...
}
But I get the following error when I try to view the page in the frontend:
[Notice] Trying to get property of non-object