Implement vertical thumbs in custom post types

How to implement this snippets in custom post types

I'm trying to implement this snippet:
https://johnregan3.co/2014/01/02/adding-support-for-vertical-featured-images-in-wordpress-themes/

...but for custom post types. How can I do that?

I want a function that automatically identify when the height is greater than the width, then append a class CSS to display the image differently.