public String getFileThumbnailUrl ( final String fileId ) { FileWidgetUpload file = getFile ( fileId ) ; if ( file == null ) { return null ; } // Check static resource Image thumbnail = file . getThumbnail ( ) ; if ( thumbnail instanceof InternalResource ) { return ( ( InternalResource ) thumbnail ) . getTargetUrl ( ) ; } Environment env = getEnvironment ( ) ; Map < String , String > parameters = env . getHiddenParameters ( ) ; parameters . put ( Environment . TARGET_ID , getTargetId ( ) ) ; if ( Util . empty ( file . getThumbnailCacheKey ( ) ) ) { // Add some randomness to the URL to prevent caching String random = WebUtilities . generateRandom ( ) ; parameters . put ( Environment . UNIQUE_RANDOM_PARAM , random ) ; } else { // Remove step counter as not required for cached content parameters . remove ( Environment . STEP_VARIABLE ) ; parameters . remove ( Environment . SESSION_TOKEN_VARIABLE ) ; // Add the cache key parameters . put ( Environment . CONTENT_CACHE_KEY , file . getThumbnailCacheKey ( ) ) ; } // File id parameters . put ( FILE_UPLOAD_ID_KEY , fileId ) ; // Thumbnail flag parameters . put ( FILE_UPLOAD_THUMB_NAIL_KEY , "Y" ) ; // The targetable path needs to be configured for the portal environment. String url = env . getWServletPath ( ) ; // Note the last parameter. In javascript we don't want to encode "&". return WebUtilities . getPath ( url , parameters , true ) ; }
Retrieves a URL for the thumbnail of an uploaded file .