I’m working on a website that can display 3D molecules (.mol) using the JavaScript-based viewer from JSmol (http://sourceforge.net/projects/jsmol/). With the “Upload File Type Settings” plug-in files with .mol extension can be uploaded as “Featured Image”.
I managed to customize my single.php template with the JSmol script to display the .mol files.
Now I’d like to determine in the template if the featured image attachment of the post is an .mol (for displaying the 3D file via the script) or an image file format (JPG, PNG.. to display with the_post_thumbnail), such as:
<?php if ("the attachment has a .mol extension?") {
echo "<script>Jmol.getTMApplet('jmol', Info)</script>";
} else if {
the_post_thumbnail();
} ?>
How can I find out which file format is used in the featured image attachment of the post?
Look at the
post_mime_type
in the$thumb
object.Reference
http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail
http://codex.wordpress.org/Function_Reference/get_post
Maybe something like this? It saves the URL to the post’s thumbnail (if set) in variable
$src
, then with a substring function you check what the last 4 letters are.