Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

fluffyghost on "How to display a default image in a custom field if there isn't any image?"

$
0
0

Hi,

Trying to figure out how to display a default image in a custom field when the user hasn't manually selected one themselves.

Here's the code I currently have that allows you to choose your own:

<figure>
<?php $image = get_field('header_image'); ?>
<?php if( !empty($image) ): ?>
<div class="headerimage clearfix">
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
</div><!--end header image-->
<?php endif; ?>
</figure>

Any ideas I would be very appreciative.


Viewing all articles
Browse latest Browse all 8245

Trending Articles