$core_v2_ui.GetPreviewHTML() returns inconsistent markup

Hi there,

The default Media - File List widget in 10.1.3.8316 is responsible for creating a list of files and includes a snippet of markup for rendering preview images/icons:

$!core_v2_ui.GetPreviewHtml($media.File.FileUrl, "%{width=100,height=100}") 

For some reason, the preview images created from this are inconsistently rendered as URLs or <img> tags containing URLs based on the file type:

Preview icon for files sometimes load images, sometimes link text

The URLs for PDF and PPTX files appear to be valid even though they aren't wrapped in an <img> tag to render them properly:

PowerPoint preview icon loads properly in a web browser

Is this the expected behavior? It doesn't behave this way in 10.0.2.

Parents
  • Here's a hacky workaround that I applied to all three of the widget's "list" VM files:

    #set ($previewIconMarkup = $core_v2_ui.GetPreviewHtml($media.File.FileUrl, "%{width=100,height=100}"))
    #if ($previewIconMarkup.toString().startsWith("<img"))
        ## Output image markup directly
        $previewIconMarkup
    #else
        ## Assume API returned a URL (may test for this later) and wrap in img tag.
        <img src="$previewIconMarkup" alt="file type icon">
    #end

Reply
  • Here's a hacky workaround that I applied to all three of the widget's "list" VM files:

    #set ($previewIconMarkup = $core_v2_ui.GetPreviewHtml($media.File.FileUrl, "%{width=100,height=100}"))
    #if ($previewIconMarkup.toString().startsWith("<img"))
        ## Output image markup directly
        $previewIconMarkup
    #else
        ## Assume API returned a URL (may test for this later) and wrap in img tag.
        <img src="$previewIconMarkup" alt="file type icon">
    #end

Children
No Data