document previews for text files

We need to share some .txt files with our clients (they're SQL scripts but easier to use in various applications if the user just downloads them as a texfile). We don't expect a preview of these files, but unfortunately there is a large white area when you open up the file in place of what would be a preview. We've created a helpful description for each file, and users may not see that description because of the large white area. Is there a way to disable previews for .txt files on our side, so the system doesn't do this? In Admin/File Viewers/Document Viewer/File Types, textfiles are not listed. 

Parents
  • Files with the extension .txt are registered as presentable by the Code File Viewer IFileViewer extension, along other common text-based file types including .sql. Unfortunately, unlike a custom IFileViewer extension, this particular file viewer extension is a core extension and cannot be disabled. 

    The easiest workaround would be to use a different file extension instead of .txt. 

    Another possibility is to customize the Media Gallery - File widget to not render file previews for files with names ending in .txt. That would require editing the content of the widget in Widget Studio.

    Change the line:

    $!core_v2_ui.GetViewHtml($media.File.FileUrl, "%{ViewType='View', AdjustToContainer='True', OutputIsPersisted='False'}")

    To:

    #if ($core_v2_utility.IsMatch($media.File.FileName, '\.txt$'))
    	$media.File.FileName
    #else
    	$!core_v2_ui.GetViewHtml($media.File.FileUrl, "%{ViewType='View', AdjustToContainer='True', OutputIsPersisted='False'}")
    #end

    It's potentially worth noting that if there is a large blank area that requires scrolling in the preview, it may be indicative of some other styling issue, as that should not be the default behavior.

  • One follow-up question (thank you). In the Code File Viewer, the file size is set to zero. Is this the problem?

Reply Children