Advertisement
Bojan_Radonic

resize for specific images / WP Smush

Jun 1st, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. /**
  2.  * Specify custom image dimension for a subset of images
  3.  *
  4.  * @param array $dimensions array(
  5.  *      'width' => 2048,
  6.  *      'height' => 2048
  7.  *  )
  8.  * @param $file_path File path for attachment being resized
  9.  * @param $id Attachment id
  10.  *
  11.  * @return array resize dimensions for the image
  12.  *
  13.  */
  14.  
  15. add_filter( 'wp_smush_resize_sizes', 'slider_images_dimensions', '', 3 );
  16.  
  17. function slider_images_dimensions( $dimensions, $file_path, $id ) {
  18.     $ids_to_be_skipped = array( 59, 60, 61 );
  19.     if ( in_array( $id, $ids_to_be_skipped ) ) {
  20.         $dimensions = array(
  21.             'width'  => 1000,
  22.             'height' => 1000
  23.         );
  24.     }
  25.  
  26.     return $dimensions;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement