Keeping the space when there is no feature image assigned (3 posts)

  1. joe1977
    Posted 4 years ago #

    I'm using the default twenty-eleven theme. I am calling the feature image of posts to be on the left and the text on the right when showing all the posts of a category as a list. It looks beautiful when there is a feature image. However, when there is no featured image, the text moves left because the div for the feature image collapses when there is no feature image.

    My question is how to keep the feature image div from collapsing when there is no content. It's similar to using "display:block" to keep a regular div from collapsing when there is no content. I've tried display:block, min-widths, etc. and nothing.

    Anyone have an idea to point me in the right direction?

  2. Michael
    Forum Moderator
    Posted 4 years ago #

    you possibly need to work with a conditional statemetn to create a spaceholder - div or image - if there is no post thumbnail;

    example for a div:

    <?php if( has_post_thumbnail() ) :
    else: ?>
    <div style="width:200px;height:150px;" class="alignleft"></div>
    <?php endif; ?>

    adjust number values to match the size of your featureed image.

    for using a default image, search the forum,
    or possibly see:

  3. joe1977
    Posted 4 years ago #

    That would work.

    However, this call for the thumbnail is an output:

    $rdscf_output.='<div class=csc_post_thumbnail>' . get_the_post_thumbnail($rdcsc_posts->ID, 'thumbnail') . '</div>';

    I don't think I can put an if/else statement in there.

    Since it's an isolated incident, I'm just uploading a blank (white) jpg the size of the feature image and assigning it as the feature image for those without.

    I would just think that there would be a less clunky work around.

Topic Closed

This topic has been closed to new replies.

About this Topic