ngg_rotate

Display the page to rotate an image.

Description

ngg_rotate( $id ); 

Parameters (1)

0. $id
Int The ID of the image.

Usage

  1. if ( !function_exists( 'ngg_rotate' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextcellent-gallery/admin/manage/actions.php'; 
  3.  
  4. // int The ID of the image. 
  5. $id = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = ngg_rotate($id); 
  9.  

Defined (1)

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

/admin/manage/actions.php  
  1. function ngg_rotate( $id ) { 
  2. //Include the graphics library 
  3. include_once( nggGallery::graphic_library() ); 
  4.  
  5. //Get the image data 
  6. $picture = nggdb::find_image( $id ); 
  7. $thumb = new ngg_Thumbnail( $picture->imagePath, true ); 
  8. $thumb->resize( 350, 350 ); 
  9.  
  10. // we need the new dimension 
  11. $resizedPreviewInfo = $thumb->newDimensions; 
  12. $thumb->destruct(); 
  13.  
  14. $preview_image = trailingslashit( home_url() ) . 'index.php?callback=image&pid=' . $picture->pid . '&width=500&height=500'; 
  15.  
  16. ?> 
  17. <p><?php _e( 'Select how you would like to rotate the image on the left.', 'nggallery' ); ?></p> 
  18. <table align="center" width="90%"> 
  19. <tr> 
  20. <td style="text-align: center; vertical-align: middle"> 
  21. <img src="<?php echo esc_url( $preview_image ); ?>" alt="" id="imageToEdit"/> 
  22. </td> 
  23. <td style="width: 200px;"> 
  24. <label><input type="radio" name="ra" value="cw"><?php esc_html_e( '90° clockwise', 'nggallery' ); ?> 
  25. </label><br> 
  26. <label><input type="radio" name="ra" value="ccw"><?php esc_html_e( '90° anticlockwise',  
  27. 'nggallery' ); ?></label><br> 
  28. <label><input type="radio" name="ra" value="fv"><?php esc_html_e( 'Flip horizontally', 'nggallery' ); ?> 
  29. </label><br> 
  30. <label><input type="radio" name="ra" value="fh"><?php esc_html_e( 'Flip vertically', 'nggallery' ); ?> 
  31. </label> 
  32. </td> 
  33. </tr> 
  34. <tr> 
  35. <td colspan="2"> 
  36. <div id="thumbMsg" style="display : none; float:right; width:60%; height:2em; line-height:2em;"></div> 
  37. </td> 
  38. </tr> 
  39. </table> 
  40. <script type="text/javascript"> 
  41. /** 
  42. * When pressed, send an AJAX request to rotate the image. 
  43. */ 
  44. doAction = function() { 
  45. var rotate_angle = jQuery('input[name=ra]:checked').val(); 
  46.  
  47. jQuery.ajax({ 
  48. url: ajaxurl,  
  49. type: "POST",  
  50. data: {action: 'rotateImage', id: <?php echo $id ?>, ra: rotate_angle},  
  51. cache: false,  
  52. success: function() { 
  53. showMessage('<?php _e('Image rotated', 'nggallery'); ?>') 
  54. },  
  55. error function() { 
  56. showMessage('<?php _e('Error rotating thumbnail', 'nggallery'); ?>') 
  57. }); 
  58. }; 
  59. </script> 
  60. <?php