I hate it when WordPress themes use post thumbnails and don’t do fallback measures. I’m looking at you, Obox.

There’s a WordPress Obox theme I’m editing right now that returns broken images when post thumbnails don’t exist. Considering this is a premium theme it’s completely stupid that I have to fix this myself. (This is why I use Get the Image most of the time, at least it’s able to pull images already entered in the post, in case the user neglects to upload post images.)

The culprit seems to be $get_thumbnail = get_post_meta($post->ID, $meta, true) returning an array instead of a correct string with the URL of the post image. Changing elseif ($get_thumbnail !== "") to ( is_string($get_thumbnail) ), which makes sure the object is a string before entering the condition. ((array) $get_thumbnail !== $get_thumbnail) could also apply, it might be marginally faster.

It’d be much better, though, if there were also a fallback image and the function didn’t just quit.

Things like these make me prefer writing themes from scratch (or at least use a non-invasive, less blundering starter theme) instead of make do with other people’s code.

Reply

Your email address will not be published. Required fields are marked *

*

Anything in between < and > will be treated as HTML.

*

%d bloggers like this: