The following functionality is additionally available for the Image content type:
git clone git://github.com/gordonbanderson/weboftalent-image-util.git cd weboftalent-image-util git checkout stable24
The name of the installation directory does not matter
Note that in cases where chaining was not possible (e.g. to set the width) an extra parameter has been added.
Assuming the Image in your model is called ThePhoto
<% control ThePhoto.RotateClockwise %> <img src="$URL"/> <% end_control %>
Check for a photograph being portrait in a template as follows:
<% if ThePhoto.IsPortrait %> This picture is portrait <% end_if %>
An example application can be found at http://www.tripodtravel.co.nz/galleries/nonthaburi/cycling-west-of-the-river/ , where a CSS class is added if the image is vertical to allow modern browsers to show EXIF data rotated.
Check for a photograph being landscape in a template as follows:
<% if ThePhoto.IsLandscape %> This picture is landscape <% end_if %>
Silverstripe's default is to show a white background when padding an image, which does not always fit with the design. This method allows the background padding color to be configured. The following example sets the background to #C9B and ensures the image fits within 300 by 100 pixels.
<% control ThePhoto.PaddedImageWithColor(CC99BB 300 100 ) %> <img src="$URL"/> <% end_control %>
A suitable place to use this might be in a rotating carousel.
Exif data is returned in a manner suitable for renering as part of a template. The sets are nested by sections. Example template for rendering below:
<% control ThePhoto.ExifData %> <h3>Section : $Name</h3> <ul> <% control Value %> <li>$Name -> $Value</li> <% end_control %> </ul> <% end_control %>
<% control Greyscale(200 30 80 200) %> <img class="greyscale" src="$URL"/> <% end_control %>
2.4 only (tested with 2.4.5+) - stable24 branch