New Google doc’s shortcode for psd, ai, svg, and more

On Friday I posted a great snippet by Joen Asmussen the Google PDF shortcode. I wanted to post an updated version primarily because the Google online viewer supports many more file types not just PDF. The supported types are .DOC, .DOCX, .XLS, .XLSX, .PPT, .PPTX, .PDF, .PAGES, .AI, .PSD, .TIFF, .DXF, .SVG, .EPS, .PS, .TTF, .XPS I added a class attribute to the shortcode that you could use to display an icon for the file type link or style the links with the default icon class.



function wps_viewer($atts, $content = null) {
"href" => 'http://',
"class" => ''
), $atts));
return '<a href="'.$href.'" class="'.$class.' icon">'.$content.'</a>';
add_shortcode("doc", "wps_viewer");

[doc class="psd" href=""]my PSD file name[/doc]
[doc class="ai" href=""]my AI file name[/doc]
[doc class="svg" href=""]my SVG file name[/doc]

Leave a comment