ngg_ajax_image_check

Test for various image resolution.

Description

ngg_ajax_image_check(); 

Usage

  1. if ( !function_exists( 'ngg_ajax_image_check' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextcellent-gallery/admin/ajax.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = ngg_ajax_image_check(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/admin/ajax.php  
  1. function ngg_ajax_image_check() { 
  2.  
  3. // check for correct NextGEN capability 
  4. if ( !current_user_can('NextGEN Upload images') ) 
  5. die('No access'); 
  6.  
  7. if ( !defined('ABSPATH') ) 
  8. die('No access'); 
  9.  
  10. $step = (int) $_POST['step']; 
  11.  
  12. // build the test sizes 
  13. $sizes = array(); 
  14. $sizes[1] = array ( 'width' => 800, 'height' => 600); 
  15. $sizes[2] = array ( 'width' => 1024, 'height' => 768); 
  16. $sizes[3] = array ( 'width' => 1280, 'height' => 960); // 1MP 
  17. $sizes[4] = array ( 'width' => 1600, 'height' => 1200); // 2MP 
  18. $sizes[5] = array ( 'width' => 2016, 'height' => 1512); // 3MP 
  19. $sizes[6] = array ( 'width' => 2272, 'height' => 1704); // 4MP 
  20. $sizes[7] = array ( 'width' => 2560, 'height' => 1920); // 5MP 
  21. $sizes[8] = array ( 'width' => 2848, 'height' => 2136); // 6MP 
  22. $sizes[9] = array ( 'width' => 3072, 'height' => 2304); // 7MP 
  23. $sizes[10] = array ( 'width' => 3264, 'height' => 2448); // 8MP 
  24. $sizes[11] = array ( 'width' => 4048, 'height' => 3040); // 12MP 
  25.  
  26. if ( $step < 1 || $step > 11 ) 
  27. die('No vaild value'); 
  28.  
  29. // let's test each image size 
  30. $temp = imagecreatetruecolor ($sizes[$step]['width'], $sizes[$step]['height'] ); 
  31. imagedestroy ($temp); 
  32.  
  33. $result = array ('stat' => 'ok', 'message' => sprintf(__('Could create image with %s x %s pixel', 'nggallery'), $sizes[$step]['width'], $sizes[$step]['height'] ) ); 
  34.  
  35. header('Content-Type: application/json; charset=' . get_option('blog_charset'), true); 
  36. echo json_encode($result); 
  37.  
  38. die();