Advertisement
neatekFb

Rational addition of image sizes (Wordpress)

Jun 7th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. <?php
  2. // Vladimir Zhelnov // neatek.ru // neatek.pw
  3. // functions.php (Wordpress)
  4.  
  5. function theme_add_image(){
  6.    
  7.     // Here is your sizes.
  8.     // usage in theme : the_post_thumbnail('538x342'); as in array, always => size - 'VALUE1xVALUE2'
  9.     $sizes = array(
  10.         [538, 342],
  11.         [209, 117],
  12.         // [WIDTH, HEIGHT],
  13.         // any new size [WIDTH, HEIGHT],
  14.     );
  15.  
  16.     foreach ($sizes as $key => $value) {
  17.         add_image_size( $value[0].'x'.$value[1], $value[0], $value[1], true );
  18.     }
  19.  
  20. }
  21.  
  22. add_action( 'init', 'theme_add_image' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement