I am building a news WordPress theme and using the Description for thumbnails to display who the photo is credited to on the website. I am then placing the credits in the Description on top of the photo using the following code. However, when the photo has no Description/credit, I do not want the description to show because the background color and padding for the Description/credit then create an empty, colored box.
I am hoping that somebody can help me with the proper if statement that will only display the Description/credit if one exists. The description is being pulled via get_post(get_post_thumbnail_id())->post_content
in the code below.
<div style="position: relative">
<?php the_post_thumbnail('large');
echo '<span style="position:absolute; bottom:9px; right:0; color:#FFF; background:rgba(0,0,0,0.8); padding:4px 6px; font-size:0.7em">';
echo get_post(get_post_thumbnail_id())->post_content;
echo '</span>'; ?>
</div>