I wanted to know if this is possible. I have gone through a lot of threads on the internet for this one and there does not seem to be one good solution. I run a business website based on wordpress and now there is this peculiar requirement wherein I need a hack/code to pull and display one single image ( from among the other images uploaded/attached to that post ).
Now the tricky part is that the image must be a horizontally/landscape oriented image only. And if it does not find a landscape image it may return nothing. Please let me know if need more clarifications.
If you must know, I already have a featured image.
Function to retrieve “landscape” oriented image
Later Usage
The above function will return the URL of the first image with an aspect ratio higher than or equal to the set minimum or
false
if none was found.Hence, if you’d like to output the image on the condition of there being one, this is how you’d go about it:
References
get_children
(WP)getimagesize
(PHP)