Last active
October 6, 2022 17:53
-
-
Save yuriinalivaiko/e3734e6f2c1ab1900dcf6a59ac9b836e to your computer and use it in GitHub Desktop.
This code snippet changes the job's company logo size in the JobBoardWP plugin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Change the job's company logo size. Get rid of the cropped square logo. Use true logo image ratio. | |
* Add this code to the file functions.php in the active theme directory. | |
*/ | |
/** | |
* Change the company logo size. | |
* | |
* @param string|int[] $size Requested image size. Can be any registered image size name, or | |
* an array of width and height values in pixels (in that order). | |
* @param int $post_id The post ID. | |
* @return string | |
*/ | |
function jb_post_thumbnail_size( $size, $post_id ) { | |
$post_type = get_post_type( $post_id ); | |
if ( 'jb-job' === $post_type && 'thumbnail' === $size ) { | |
/** | |
* Available size names: 'thumbnail', 'medium', 'large', 'origin'. | |
* Default size name: 'thumbnail'. | |
* Recommended size name: 'medium'. | |
*/ | |
$size = 'medium'; | |
} | |
return $size; | |
} | |
// Change the company logo on the Jobs page. | |
add_filter( 'jb_get_jobs_query_args', function( $query_args ) { | |
add_filter( 'post_thumbnail_size', 'jb_post_thumbnail_size', 10, 2 ); | |
return $query_args; | |
} ); | |
// Change the company logo on the single Job page. | |
add_action( 'jb_before_job_content', function ( $post_id ) { | |
add_filter( 'post_thumbnail_size', 'jb_post_thumbnail_size', 10, 2 ); | |
} ); | |
// Change the company logo styles. | |
add_action( 'wp_footer', function() { | |
?> | |
<style type="text/css"> | |
.jb-jobs .jb-jobs-wrapper .jb-job-list-row .jb-job-logo div.jb-job-company-logo-wrapper, | |
.jb .jb-job-company .jb-job-company-info .jb-job-logo div.jb-job-company-logo-wrapper { | |
height: auto; | |
overflow: visible; | |
} | |
</style> | |
<?php | |
} ); | |
/** | |
* Documentation: https://docs.jobboardwp.com/ | |
* Support forum: https://wordpress.org/support/plugin/jobboardwp/ | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: