Created
February 18, 2015 13:10
-
-
Save maor/e2aabd7d2bbf79b2c305 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function maor_image_proportions_classes($attr, $attachment) { | |
$image = wp_get_attachment_image_src( $attachment->ID, 'full', false ); | |
if ( ! $image ) | |
return $attr; | |
list( $src, $width, $height ) = $image; | |
$attr['class'] .= ( $height > $width ) ? ' wp-image-portrait' : ' wp-image-landscape'; | |
return $attr; | |
} | |
add_filter( 'wp_get_attachment_image_attributes', 'maor_image_proportions_classes', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment