Adding portrait | landscape class
-
Was needing to add .portrait / .landscape classes for a custom gallery implementation I was doing. Approached it by modifying the gallery.php file, figured I’d post here incase anyone else needed the same function.
Insert the following at line 130 ( before the comment /* Open each gallery item. */ ):
/* Get Image Meta */ $image_meta = get_post_meta($attachment->ID,'_wp_attachment_metadata',TRUE); /* Check Orientation ( Portrait / Landscape ) */ $orientation = $image_meta['height'] > $image_meta['width'] ? 'portrait' : 'landscape';
then modify the following line to include the variable for orientation in the class:
/* Open each gallery item. */ $output .= "\n\t\t\t\t\t<{$itemtag} class='gallery-item col-{$columns} {$orientation}'>";
- The topic ‘Adding portrait | landscape class’ is closed to new replies.