Last active
          January 17, 2022 19:52 
        
      - 
      
- 
        Save rafaehlers/dee3b64991451694b4a54c7c478657bf to your computer and use it in GitHub Desktop. 
    Remove Lightbox from PDFs
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| add_filter('gravityview/fields/fileupload/files_array', 'gv_modify_files_output_pdf',10,1); | |
| function gv_modify_files_output_pdf($output_arr){ | |
| foreach ($output_arr as $key => $value) { | |
| $pdf_exists = strpos($value['file_path'], '.pdf'); | |
| if ($pdf_exists !== false) { | |
| $gf_download = strpos($value['file_path'],'?gf-download='); | |
| if ($gf_download == false) { | |
| $gravity_forms = strpos($value['file_path'],'/gravity_forms/'); | |
| $file_name = substr($value['file_path'], $gravity_forms + 59); | |
| $gv_iframe = strpos($file_name,'?gv-iframe=true'); | |
| $file_name = substr($file_name, 0, $gv_iframe); | |
| }else{ | |
| $file_name = urldecode(substr($value['file_path'], $gf_download + 25, $pdf_exists-($gf_download+21))); | |
| } | |
| $output_arr[$key]['content'] = '<a href="'.$value['file_path'].'" target="_blank">'.$file_name.'</span></a>'; | |
| } | |
| } | |
| return $output_arr; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment