Support » Themes and Templates » Post Image – does it expect every post to have an image?

  • Mark

    (@codeispoetry)


    I’m trying to use the Post Image plugin (v. 1.1.1, i.e. most recent version) on a recent project, but I’m running into problems with posts that don’t have an associated image. This happens despite the fact that I’m using the conditional given as an example on the plugin page:

    <?php $thumb = szub_post_image('use_thumb=1&display=0'); ?>
    <?php if($thumb) : ?>
    <a href="<?php the_permalink(); ?>"><?php echo $thumb; ?></a>
    <?php endif; : ?>

    I use this within the loop, nothing special. I expect this code to check whether there is any thumb, and to return nothing if there is nothing. It turns out, however, that $thumb is somehow set (or at least not empty) even if there is no image associated with the post. On a page listing 10 posts of which two have an associated image, the result is that empty <img> tags are scattered all over the place.

    Hence my question: does Post Image actually expect every post to have an image? If it does, could anyone give me a lead on how to solve my particular problem, on what to do when a post doesn’t have one? If it doesn’t, what am I doing wrong?

Viewing 1 replies (of 1 total)
  • Mark

    (@codeispoetry)

    Follow-up: a temporary solution is to specify a default image. Then the empty <img> elements are gone, obviously. However, that’s not what I need; for some posts I’d like to have a picture, for others I don’t.

Viewing 1 replies (of 1 total)
  • The topic ‘Post Image – does it expect every post to have an image?’ is closed to new replies.