gdwpm_filter_gbrurl

The Google Drive WP Media gdwpm filter gbrurl function.

Description

gdwpm_filter_gbrurl( $url ); 

Parameters (1)

0. $url
The url.

Usage

  1. if ( !function_exists( 'gdwpm_filter_gbrurl' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-drive-wp-media/google-drive-wp-media.php'; 
  3.  
  4. // The url. 
  5. $url = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = gdwpm_filter_gbrurl($url); 
  9.  

Defined (1)

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

/google-drive-wp-media.php  
  1. function gdwpm_filter_gbrurl( $url ) { 
  2. $upload_dir = wp_upload_dir(); 
  3. if (strpos($url, 'G_D_W_P_M-ImageFile_ID/') !== false) { 
  4. $url = str_replace( $upload_dir['baseurl'] . '/G_D_W_P_M-ImageFile_ID/', GD_BASE_PATH, $url ); 
  5. if(strpos($url, GD_BASE_PATH) === false) { 
  6. $url = GD_BASE_PATH . substr($url, strrpos($url, '/') + 1); 
  7. } elseif (strpos($url, 'G_D_W_P_M-file_ID/') !== false) { 
  8. $url = str_replace( $upload_dir['baseurl'] . '/G_D_W_P_M-file_ID/', 'https://docs.google.com/uc?id=', $url ) . '&export=view'; 
  9. if(strpos($url, 'https://docs.google.com/uc?id=') === false) { 
  10. $url = 'https://docs.google.com/uc?id=' . substr($url, strrpos($url, '/') + 1); 
  11. return $url;