Set default image for company

Currently, if you do not provide the company image default icon with the factory will be displayed. We understand that in some cases, you want to display one logo or have some image instead of an icon. You can easily achieve this using a simple code snippet.

If you do not know how to add snippets properly, take a look at our documentation file, where we explained how you can do this.

add_filter('wpjb_scheme', 'set_default_company_logo_renderer');
function set_default_company_logo_renderer($scheme) {
    $scheme["field"]["company_logo"]["render_callback"] = "display_default_company_logo";
    return $scheme;
}
function display_default_company_logo( $company ) {

    // Check if the company have uploaded logo
    if($company->getLogoUrl()) {
        echo '<div>';
        echo '<img src="<?php echo $company->getLogoUrl("50x50") ?>" alt="" />';
        echo '</div>';
    } else {
        echo '<div>';
        echo '<img src="http://url_to_my_default_logo/image.jpg" />';
        echo '</div>';
    }
}

If a company has its own logo, display it, if not display provided image. Of course on this stage, you can add some styling for the image if you want.

 

 

 

Leave a Reply

Your email address will not be published.