optionsframework_medialibrary_uploader

The Evolved optionsframework medialibrary uploader function.

Description

optionsframework_medialibrary_uploader( $_id, $_value, (string) $_mode = 'full', (string) $_desc = '', (int) $_postid = 0, (string) $_name = '' ); 

Parameters (6)

0. $id
The id.
1. $value
The value.
2. $mode — Optional. (string) => 'full'
The mode.
3. $desc — Optional. (string) => ''
The desc.
4. $postid — Optional. (int)
The postid.
5. $name — Optional. (string) => ''
The name.

Usage

  1. if ( !function_exists( 'optionsframework_medialibrary_uploader' ) ) { 
  2. require_once '/admin/options-framework/options-medialibrary-uploader.php'; 
  3.  
  4. // The id. 
  5. $id = null; 
  6.  
  7. // The value. 
  8. $value = null; 
  9.  
  10. // The mode. 
  11. $mode = 'full'; 
  12.  
  13. // The desc. 
  14. $desc = ''; 
  15.  
  16. // The postid. 
  17. $postid = -1; 
  18.  
  19. // The name. 
  20. $name = ''; 
  21.  
  22. // NOTICE! Understand what this does before running. 
  23. $result = optionsframework_medialibrary_uploader($id, $value, $mode, $desc, $postid, $name); 
  24.  

Defined (1)

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

/admin/options-framework/options-medialibrary-uploader.php  
  1. function optionsframework_medialibrary_uploader( $_id, $_value, $_mode = 'full', $_desc = '', $_postid = 0, $_name = '') { 
  2.  
  3. $optionsframework_settings = get_option('optionsframework'); 
  4.  
  5. // Gets the unique option id 
  6. $option_name = $optionsframework_settings['id']; 
  7.  
  8. $output = ''; 
  9. $id = ''; 
  10. $class = ''; 
  11. $int = ''; 
  12. $value = ''; 
  13. $name = ''; 
  14.  
  15. $id = strip_tags( strtolower( $_id ) ); 
  16. // Change for each field, using a "silent" post. If no post is present, one will be created. 
  17.  
  18. // If a value is passed and we don't have a stored value, use the value that's passed through. 
  19. if ( $_value != '' && $value == '' ) { 
  20. $value = $_value; 
  21.  
  22. if ($_name != '') { 
  23. $name = $option_name.'['.$id.']['.$_name.']'; 
  24. else { 
  25. $name = $option_name.'['.$id.']'; 
  26.  
  27. if ( $value ) { $class = ' has-file'; } 
  28. $output .= '<input id="' . $id . '" class="upload' . $class . '" type="text" name="'.$name.'" value="' . $value . '" />' . "\n"; 
  29. $output .= '<input id="upload_' . $id . '" class="upload_button button" type="button" value="' . __( 'Upload', 'optionsframework') . '" rel="' . $int . '" />' . "\n"; 
  30.  
  31. if ( $_desc != '' ) { 
  32. $output .= '<span class="of_metabox_desc">' . $_desc . '</span>' . "\n"; 
  33.  
  34. $output .= '<div class="screenshot" id="' . $id . '_image">' . "\n"; 
  35.  
  36. if ( $value != '' ) {  
  37. $remove = '<a href="javascript:(void);" class="mlu_remove button">Remove</a>'; 
  38. $image = preg_match( '/(^.*\.jpg|jpeg|png|gif|ico*)/i', $value ); 
  39. if ( $image ) { 
  40. $output .= '<img src="' . $value . '" alt="" />'.$remove.''; 
  41. } else { 
  42. $parts = explode( "/", $value ); 
  43. for( $i = 0; $i < sizeof( $parts ); ++$i ) { 
  44. $title = $parts[$i]; 
  45.  
  46. // No output preview if it's not an image.  
  47. $output .= ''; 
  48.  
  49. // Standard generic output if it's not an image.  
  50. $title = __( 'View File', 'optionsframework' ); 
  51. $output .= '<div class="no_image"><span class="file_link"><a href="' . $value . '" target="_blank" rel="external">'.$title.'</a></span>' . $remove . '</div>'; 
  52. }  
  53. $output .= '</div>' . "\n"; 
  54. return $output; 
  55. }