media_upload_nextgen

The NextGEN Gallery media upload nextgen function.

Description

media_upload_nextgen(); 

Usage

  1. if ( !function_exists( 'media_upload_nextgen' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextgen-gallery/products/photocrati_nextgen/modules/ngglegacy/admin/media-upload.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = media_upload_nextgen(); 
  7.  

Defined (1)

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

/products/photocrati_nextgen/modules/ngglegacy/admin/media-upload.php  
  1. function media_upload_nextgen() { 
  2.  
  3. // Not in use 
  4. $errors = false; 
  5.  
  6. // Generate TinyMCE HTML output 
  7. if ( isset($_POST['send']) ) { 
  8. $keys = array_keys($_POST['send']); 
  9. $send_id = (int) array_shift($keys); 
  10. $image = $_POST['image'][$send_id]; 
  11. $alttext = stripslashes( htmlspecialchars ($image['alttext'], ENT_QUOTES)); 
  12. $description = stripslashes (htmlspecialchars($image['description'], ENT_QUOTES)); 
  13.  
  14. // here is no new line allowed 
  15. $clean_description = preg_replace("/\n|\r\n|\r$/", " ", $description); 
  16. $img = nggdb::find_image($send_id); 
  17. $thumbcode = $img->get_thumbcode(); 
  18. $class="ngg-singlepic ngg-{$image['align']}"; 
  19.  
  20. // Create a shell displayed-gallery so we can inspect its settings 
  21. $registry = C_Component_Registry::get_instance(); 
  22. $mapper = $registry->get_utility('I_Displayed_Gallery_Mapper'); 
  23. $factory = $registry->get_utility('I_Component_Factory'); 
  24. $args = array( 
  25. 'display_type' => NGG_BASIC_SINGLEPIC 
  26. ); 
  27. $displayed_gallery = $factory->create('displayed_gallery', $args, $mapper); 
  28. $width = $displayed_gallery->display_settings['width']; 
  29. $height = $displayed_gallery->display_settings['height']; 
  30.  
  31. // Build output 
  32. if ($image['size'] == "thumbnail") 
  33. $html = "<img src='{$image['thumb']}' alt='{$alttext}' class='{$class}' />"; 
  34. else 
  35. $html = ''; 
  36.  
  37. // Wrap the link to the fullsize image around 
  38. $html = "<a {$thumbcode} href='{$image['url']}' title='{$clean_description}'>{$html}</a>"; 
  39.  
  40. if ($image['size'] == "full") 
  41. $html = "<img src='{$image['url']}' alt='{$alttext}' class='{$class}' />"; 
  42.  
  43. if ($image['size'] == "singlepic") 
  44. $html = "[singlepic id={$send_id} w={$width} h={$height} float={$image['align']}]"; 
  45.  
  46.  
  47. // Return it to TinyMCE 
  48. return media_send_to_editor($html); 
  49.  
  50. // Save button 
  51. if ( isset($_POST['save']) ) { 
  52.  
  53. return wp_iframe( 'media_upload_nextgen_form', $errors );