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) {
extract(shortcode_atts(array(
"href" => 'http://',
"class" => ''
), $atts));
return '<a href="http://docs.google.com/viewer?url='.$href.'" class="'.$class.' icon">'.$content.'</a>';
}
add_shortcode("doc", "wps_viewer");

[doc class="psd" href="http://www.wpsnipp.com/file.psd"]my PSD file name[/doc]
[doc class="ai" href="http://www.wpsnipp.com/file.ai"]my AI file name[/doc]
[doc class="svg" href="http://www.wpsnipp.com/file.svg"]my SVG file name[/doc]

Be Sociable, Share!

Leave a comment