samedi 23 juillet 2016

put default image if there is no image using ACF

I am using Wordpress ACF plugin and I have custom products section and I put a custom field for featured Image and its working perfect, Now I want If there is no featured image inserted then show a default image, I am using the following code but its not working.

                <?php
            $category_image = get_field('fimage');
            if($category_image){
                $category_image_url = $category_image['sizes']['product-thumb'];
            }
                 if($category_image_url) { ?>
                            <img src="<?php echo esc_url( get_template_directory_uri() ); ?>/timthumb.php?src=<?php echo $category_image['url']; ?>&w=300&h=250&zc=0" alt="<?php echo $category_image['name']; ?>" title="<?php echo $category_image['name']; ?>">
}                       else($category_image_url) { ?>
                            <img src="http://www.staticwhich.co.uk/static/images/products/no-image/no-image-available.png" alt="<?php echo $category_image['name']; ?>" title="<?php echo $category_image['name']; ?>">
                        <?php } ?>

Aucun commentaire:

Enregistrer un commentaire