WordPress Image Orientation Detection
WordPress introduced responsive images in 4.4 which I find to work great in most cases.
I have run across a few situations where I wanted more granular control over the image sizes and how they display based upon the images orientation.
I decided the best way for me to implement something like this was using CSS classes. This would require me to filter the WordPress thumbnail image with a php function:
You pass the image size in as a parameter, the function then uses
wp_get_attachment_image_src to get the height and width of the image.
If the orientation is landscape, it adds the class
r0bsc0tt-landscape to the image.
If the orientation is portrait, it adds the class
r0bsc0tt-portrai to the image.