Title: Adding portrait | landscape class
Last modified: August 20, 2016

---

# Adding portrait | landscape class

 *  [thowmas](https://wordpress.org/support/users/thowmas/)
 * (@thowmas)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/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}'>";
       ```
   
 * [http://wordpress.org/extend/plugins/cleaner-gallery/](http://wordpress.org/extend/plugins/cleaner-gallery/)

The topic ‘Adding portrait | landscape class’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/cleaner-gallery_cfd5de.svg)
 * [Cleaner Gallery](https://wordpress.org/plugins/cleaner-gallery/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cleaner-gallery/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cleaner-gallery/)
 * [Active Topics](https://wordpress.org/support/plugin/cleaner-gallery/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cleaner-gallery/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cleaner-gallery/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [thowmas](https://wordpress.org/support/users/thowmas/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/adding-portrait-landscape-class/)
 * Status: not resolved