Home › Forums › ACF PRO › Image-Not-Available option › Reply To: Image-Not-Available option
I don’t follow you. It’s a stretch beyond my comfort zone, I suppose.
I have this working (adapted from ACF website snippet):
<?php
$image = get_field('photo102');
if( !empty($image) ):
// vars
$url = $image['url'];
$title = $image['title'];
$alt = $image['alt'];
$caption = $image['caption'];
// thumbnail
$size = 'member-listing';
$thumb = $image['sizes'][ $size ];
$width = $image['sizes'][ $size . '-width' ];
$height = $image['sizes'][ $size . '-height' ];
if( $caption ): ?>
<div class="wp-caption">
<?php endif; ?>
<!-- see single-cdtxprofessional.php in this area for code for adding link to picture itself if you want that -->
<img src="<?php echo $thumb; ?>" alt="<?php echo $alt; ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>" />
</a>
<?php if( $caption ): ?>
<p class="wp-caption-text"><?php echo $caption; ?></p>
</div>
<?php endif; ?>
<?php endif; ?>
So, if the user doesn’t add an image here, I would like a default alternate. If I do the global ACF options method, I’m not clear on how I add the function with a priority less than 99. Also don’t know where I put such code, in theme functions or a plugin? Sorry, as I’m a bit green here.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.