Wordpress- How to Customise Divi Thumbnail Sizes

Topic:

How can we customise Divi Thumbnail Sizes?

Solution:

To customise the index and archive page, as well as single post thumbnails using different filters.

Below is the code, you can just remove or comment out the filters if you don’t want to use them.

 
/**
 * Set blog, index, archive & post thumbnail sizes
 */


/* Blog */
function wpaft_blog_thumbnail_width( $width ) {
 return 150; //blog thumbnail width in pixels
}
add_filter( 'et_pb_blog_image_width', 'wpaft_blog_thumbnail_width');
function wpaft_blog_thumbnail_height( $height ) {
 return 150; //blog thumbnail height in pixels
}
add_filter( 'et_pb_blog_image_height', 'wpaft_blog_thumbnail_height');


/* Index & archive */
function wpaft_index_thumbnail_width( $width ) {
 if( !is_single() ) {
   return 150; //index thumbnail width in pixels
 } else {
  return $width;
 }
}
add_filter( 'et_pb_index_blog_image_width', 'wpaft_index_thumbnail_width');
function wpaft_index_thumbnail_height( $height ) {
 if( !is_single() ) {
  return 150; //index thumbnail height in pixels
 } else {
  return $height;
 }
}
add_filter( 'et_pb_index_blog_image_height', 'wpaft_index_thumbnail_height');


/* Post */
function wpaft_post_thumbnail_width( $width ) {
 if( is_single() ) {
   return 300; //post thumbnail width in pixels
 } else {
  return $width;
 }
}
add_filter( 'et_pb_index_blog_image_width', 'wpaft_post_thumbnail_width');
function wpaft_post_thumbnail_height( $height ) {
 if( is_single() ) {
  return 300; //post thumbnail height in pixels
 } else {
  return $height;
 }
}
add_filter( 'et_pb_index_blog_image_height', 'wpaft_post_thumbnail_height');

No comments:

Post a Comment