I have a view that outputs an image field. I would like to add a class to the .views-field
div (for example, actually a views-row
would also do the job) depending on whether the image is vertical (length > height) or horizontal (height > width).
I tried making a custom views-view-field-tpl.php
for outputting the view's field, but I have no idea how to access the image or the image data.
EDIT: I've found that $field
contains additional_fields
, which in turns includes field_photo_width
and field_photo_height
. Those are arrays, though, and I have no idea how to get an actual value from them.
$array['value']
. And object properties/methods can be accessed with an arrow$object->property
. You can also have arrays inside objects:$node->field_body['value']
.