Here's a suggestion. Use some arrays to store the extensions you want to test for as well as the resulting classes you want to apply to that div. Then call a custom function to test what extension is in use and apply the appropriate class via the .addClass() method. Here's a JS Fiddle you can have a look at to see it all in action.
http://jsfiddle.net/HZnx5/10/
Try changing the extension to 'png' or 'jpg' to see the change. I added some simple CSS just to illustrate things a bit more clearly. Best of luck! - Jesse
PS Here's the JS code here for reference:
$(function(){
var mediaExtensions = ['mp4', 'jpg', 'png']; //array of whatever types you want to check against
var mediaTypes = ['video', 'image']; //array of corresponding classes you want to use
var dataItem = $('.data'); //a JQ object correseponding to the '.data' element to add the class to
function doClassChange(el) {
var elItem = $(el); //corresponds to the element you want to add the class to
var mediaExtension = elItem.find('.media').text().split('.'); //getting the extension
mediaExtension = mediaExtension[mediaExtension.length - 1];
var mediaType; //the class we're going to add to the dataItem element
switch (mediaExtension) {
case mediaExtensions[0]:
//mp4
mediaType = mediaTypes[0]; //video type
break;
case mediaExtensions[1]:
//jpg - same case as png
case mediaExtensions[2]:
//png - same as jpg
mediaType = mediaTypes[1]; //image type
break;
default:
mediaType = 'undefined'; //or whatever other value you'd like to have by default
}
return mediaType;
}
dataItem.addClass(doClassChange(this)); //adding the class to the dataItem, and calling a function which does all of the logic
});