Adding Custom Image Sizes


/ Published in: PHP
Save to your folder(s)

for adding custom image sizes you can select from media uploader

Credit: pippinsplugins.com/add-custom-image-sizes-to-media-uploader/


Copy this code and paste it in your HTML
  1. <?php
  2. function pw_add_image_sizes() {
  3. add_image_size( 'pw-thumb', 300, 100, true );
  4. add_image_size( 'pw-large', 600, 300, true );
  5. }
  6. add_action( 'init', 'pw_add_image_sizes' );
  7.  
  8. function pw_show_image_sizes($sizes) {
  9. $sizes['pw-thumb'] = __( 'Custom Thumb', 'pippin' );
  10. $sizes['pw-large'] = __( 'Custom Large', 'pippin' );
  11.  
  12. return $sizes;
  13. }
  14. add_filter('image_size_names_choose', 'pw_show_image_sizes');

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.