• David Abbott

    (@we-are-chesapeake)


    Hi all.

    Does anyone know how I could go about distinguishing between portrait and landscape images? I would like to append different CSS classes to both. Many thanks, and appreciation.

Viewing 3 replies - 1 through 3 (of 3 total)
  • How are you uploading the images? The built in Media Uploader will create some meta-data about your image, including the height and width. Its pretty simple to check the height an width relationship to find out which is larger.

    Thread Starter David Abbott

    (@we-are-chesapeake)

    Yes, uploading through the Media Uploader.

    “Its pretty simple to check the height an width relationship to find out which is larger.”

    Unfortunately not so simple that I can figure it out! Any tips, or places to read more?

    Well, if you are inserting the images into the post you can just add the class you want right there in the html editor.

    If you can’t write it into the editor for some reason or want to automate it you can use wp_get_attachment_metadata() to get an array of various image properties, including height and width. So you could parse that as the image gets displayed and assign the appropriate class(es) for the image type.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘distinguishing between portrait & landscape’ is closed to new replies.